标签:long和日期转化
package p1; import java.text.SimpleDateFormat; import java.util.Date; public class ts { public static void main(String[] args){ // Calendar calendar = Calendar.getInstance(Locale.CHINA); // long timeStamp = calendar.getTime().getTime()/1000; Date date = new Date(); long timeStamp = date.getTime(); System.out.println(timeStamp); System.out.println(transferLongToDate(timeStamp)); } private static String transferLongToDate(Long millSec){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:sss"); Date date= new Date(millSec); return sdf.format(date); } }
我习惯性把日期格式的全小写,然后发现数据不对劲,百度了一下,发现m M d D大小写代表不同的意义,参考http://www.blogjava.net/algz/articles/324727.html,感谢博主~
标签:long和日期转化
原文地址:http://smileyes.blog.51cto.com/6027700/1637976