• java+selenium+new——格式化时间


    package rjcs;
    
    
    
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.*;
    import java.awt.*;
    import java.awt.datatransfer.StringSelection;
    import java.awt.event.KeyEvent;
    import java.io.File;
    
    import org.apache.commons.io.FileUtils;
    import org.openqa.selenium.support.*;
    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.Keys;
    import org.openqa.selenium.OutputType;
    import org.openqa.selenium.TakesScreenshot;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.firefox.FirefoxProfile;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.support.ui.Select;
    
    public class xinkaishi 
    {
    
        
        public static void main(String[] args)
        
        {
             System.setProperty("webdriver.firefox.bin","C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");    //设置火狐的安装路径,防止系统找不到
                
             FirefoxDriver driver = new FirefoxDriver();        //初始化FireFox浏览器实例,并打开浏览器
             
            try
            {
                 driver.manage().window().maximize();         //最大化窗口
                 
                 driver.navigate().to("https://www.baidu.com"); 
                 
                 Thread.sleep(5000);
                 
                 
                 DateFormat dateformat1= new SimpleDateFormat("yyyy-MM-dd");  //创建一个data format对象
                 Date date1 = new Date();  //利用Date()获取当前时间            
                 String datex = dateformat1.format(date1);    //格式化时间,并用String对象存储        
                 System.out.println(datex);   //打印格式化时间到控制台
                 
    
                 DateFormat dateformat2= new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");  //创建一个data format对象
                 Date date2 = new Date();  //利用Date()获取当前时间            
                 String datey = dateformat2.format(date2);    //格式化时间,并用String对象存储        
                 System.out.println(datey);   //打印格式化时间到控制台
                 
                 
                 
                 DateFormat dateformat3= new SimpleDateFormat("HH-mm-ss");  //创建一个data format对象
                 Date date3 = new Date();  //利用Date()获取当前时间            
                 String dateu = dateformat3.format(date3);    //格式化时间,并用String对象存储        
                 System.out.println(dateu);   //打印格式化时间到控制台
    
                 
                 Thread.sleep(5000);
                 
                 
                 
            }catch (Exception e) 
            {
                e.printStackTrace();
            }finally 
            {
                driver.quit();
            
             }
        }
        
        
        
    }

    执行结果:

    2020-02-11
    2020-02-11-16-35-11
    16-35-11

  • 相关阅读:
    快速幂,矩阵乘法,矩阵快速幂
    关于xor
    数位dp
    tarjan,割边,桥,割点
    RMQ,ST表,dp
    逆序对,树状数组,归并排序
    线段树
    dp,LCS
    清北 游
    青蛙的约会(扩展欧几里得)
  • 原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12295618.html
Copyright © 2020-2023  润新知