zoukankan      html  css  js  c++  java
  • Android中System.currentTimeMillis()

    函数:
    System.currentTimeMillis();

    功能:产生一个当前的毫秒,这个毫秒事实上就是自1970年1月1日0时起的毫秒数,Date()事实上就是相当于Date(System.currentTimeMillis());

    由于Date类还有构造Date(long date),用来计算long秒与1970年1月1日之间的毫秒差。


    得到了这个毫秒数。利用函数Calendar终于出的结果就是年月日分秒。

    System.currentTimeMillis() ;

    获得的是自1970-1-01 00:00:00.000 到当前时刻的时间距离,类型为long

    String.valueOf(System.currentTimeMillis()) 这个语句可转为下面的型式:
    long ct = System.currentTimeMillis();
    String t = String.valueOf(ct);

    事实上上面的String t就相当于 ct+"",仅仅是转为字符串格式。


    public String refFormatNowDate() {
      Date nowTime = new Date(System.currentTimeMillis());
      SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd");
      String retStrFormatNowDate = sdFormatter.format(nowTime);
      return retStrFormatNowDate;
    }





  • 相关阅读:
    宿主机无法访问CentOS7上Jenkins服务的解决办法
    415. Add Strings
    367. Valid Perfect Square
    326. Power of Three
    258. Add Digits
    231. Power of Two
    204. Count Primes
    202. Happy Number
    172. Factorial Trailing Zeroes
    171. Excel Sheet Column Number
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/5180408.html
Copyright © 2011-2022 走看看