• java如何获取当前时间,精确到毫秒


    import java.text.SimpleDateFormat;
    
    import java.util.Date;
    
    import java.util.Calendar;
    
    //func1
    Calendar Cld = Calendar.getInstance();
    int YY = Cld.get(Calendar.YEAR) ;
    int MM = Cld.get(Calendar.MONTH)+1;
    int DD = Cld.get(Calendar.DATE);
    int HH = Cld.get(Calendar.HOUR_OF_DAY);
    int mm = Cld.get(Calendar.MINUTE);
    int SS = Cld.get(Calendar.SECOND);
    int MI = Cld.get(Calendar.MILLISECOND);    
    //由整型而来,因此格式不加0,如  2016/5/5-1:1:32:694
    System.out.println(YY + "/" + MM + "/" + DD + "-" + HH + ":" + mm + ":" + SS + ":" + MI);
    
    //func2
    Calendar cal = Calendar.getInstance(); 
    Date date = cal.getTime();
    //  2016/05/05-01:01:34:364
    System.out.println(new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss:SSS").format(date));
    
    //func3  2016/05/05-01:01:34:364
    System.out.println(new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss:SSS").format(new Date()));

    注:参考链接:http://www.cnblogs.com/cnblogszs/p/5508223.html

  • 相关阅读:
    Apple Swift编程语言入门教程
    网络请求错误
    Mac使用大全
    MPMovieplayerController添加新控件
    ios9 新变化
    UITableView总结
    UINavigationController的简单学习
    HTML
    谓词(NSPredicate)
    NSString字符串
  • 原文地址:https://www.cnblogs.com/kings-9/p/7629241.html
Copyright © 2020-2023  润新知