将整数时间戳转换为java日期 [英] Converting Integer time stamp into java date
本文介绍了将整数时间戳转换为java日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1333125342
我可以使用SQL进行转换:
select DATEADD ,FLOOR(1333089223/86400)* 86400,'1970-01-01 00:00:00')AS日期
如何在java中转换?所以它会返回值:
3/30/12 12:18:43 PM
解决方案
假设它是从1/1/1970秒开始的时间。你可以尝试
String dateAsText = new SimpleDateFormat(yyyy-MM-dd HH:mm:ss)
.format(new Date(1333125342 * 1000L));
I have following time stamp in Integer form
1333125342
I can convert it using SQL:
select DATEADD(ss, FlOOR(1333089223/86400)*86400, '1970-01-01 00:00:00') AS Date
How to convert it in java? So that it would return value:
3/30/12 12:18:43 PM
解决方案
Assuming its the time since 1/1/1970 in seconds. you can try
String dateAsText = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(new Date(1333125342 * 1000L));
这篇关于将整数时间戳转换为java日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文