当前位置: 代码迷 >> Android >> 初记:获取系统时间的long值,格式化成可读时间
  详细解决方案

初记:获取系统时间的long值,格式化成可读时间

热度:84   发布时间:2016-04-24 12:01:25.0
小记:获取系统时间的long值,格式化成可读时间。
 1     /** 2      * 返回的字符串形式是形如:2013年10月20日 20:58 3      * */ 4     public static String formatTimeInMillis(long timeInMillis) { 5         Calendar cal = Calendar.getInstance(); 6         cal.setTimeInMillis(timeInMillis); 7         Date date = cal.getTime(); 8         SimpleDateFormat dateFormat = new SimpleDateFormat( 9                 "yyyy年MM月dd日 HH:mm:ss");10         String fmt = dateFormat.format(date);11 12         return fmt;13     }

 

  相关解决方案