3

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

Json timestamp Example: 1365427692
StaxMan
  • 108,392
  • 32
  • 202
  • 235
Tien Nguyen
  • 4,108
  • 9
  • 29
  • 43
  • 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
  • 19,081
  • 10
  • 86
  • 147
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
  • 262,936
  • 84
  • 758
  • 1,028