3

How can i convert a Javascript timestamp in JSON to java timestamp?

Json timestamp Example: 1365427692
StaxMan
  • 113,358
  • 34
  • 211
  • 239
Tien Nguyen
  • 4,298
  • 9
  • 30
  • 44
  • 3
    Looks like timestamp in seconds, just multiply by 1000 to get milliseconds for Java timestamp. – denis.solonenko Apr 11 '13 at 08:25
  • Read this: http://stackoverflow.com/questions/3371326/java-date-from-unix-timestamp from the question: java.util.Date time=new java.util.Date((long)timeStamp*1000); – xkickflip Apr 11 '13 at 08:38

2 Answers2

0
private Date JSONTarihConvert(String tarih) throws ParseException{
    long timestamp = getTimeStampFromTarih(tarih);
    return new Date(timestamp);
}

More info here

Community
  • 1
  • 1
Daniel
  • 20,420
  • 10
  • 92
  • 149
0

java.time

The modern way is with java.time classes.

Instant instant = Instant.ofEpochSecond( 1365427692L );

An Instant is a moment on the timeline in UTC with a resolution of nanoseconds.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154