Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java convert long time to java.util.Date

Tags:

java

why this is different:
select from_unixtime(1383699655), I get '2013-11-06 09:00:55', but when I convert 1383699655 to
java.util.Date,new Date(1383699655), I get the Sat Jan 17 08:21:43 CST 1970

like image 226
Duke Avatar asked Dec 09 '22 10:12

Duke


1 Answers

The unix timestamp is in seconds and java Date needs milliseconds.

Thus you must convert

 new Date(1383699655 * 1000L)
like image 78
René Link Avatar answered Dec 11 '22 08:12

René Link