java日期与时间戳相互转换
//时间戳转化为Sting或Date
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Long time=newLong(445555555);
String d = format.format(time);
Date date=format.parse(d);
System.out.println("Format To String(Date):"+d);
System.out.println("Format To Date:"+date);
//日期转换成时间戳
date.getTime()/1000
注:若出现时间戳转日期显示1970,则查看时间戳对不对,有没有*1000L
本文为胖虎原创文章,转载无需和我联系,但请注明来自胖虎博客panghucat.cn