java convert long time to java.util.Date

Viewed 727

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

2 Answers

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

Thus you must convert

 new Date(1383699655 * 1000L)

Java time is milliseconds passed Jan 01 1970 00:00. Unix time is seconds. Multiply by 1000.

Related