Daniel A. White Daniel A. White - 11 months ago 59
JSON Question

JSON `date(...)` to `java.Util.Date` using `org.json`

I'm learning Java and writing an android app that consumes a JSON object that is passed by the server.

I have it all working except the dates.

I get one of these back


I am using

How do i convert
into a


Date format is not standard in JSON, so you need to choose how you "pass it through". I think the value you are seeing is in millis.

In Java:

System.out.println (new Date(1263798000000L));
// prints: Mon Jan 18 09:00:00 IST 2010

This is in my timezone, of course, but in any case it is a fairly recent date.

From the javadoc of the Date constructor:

date - the milliseconds since January 1, 1970, 00:00:00 GMT.

Link to the docs here -> http://java.sun.com/javase/6/docs/api/java/util/Date.html#Date%28long%29