I got the following date input Sat May 23 18:09:05 EEST 2015 ,
how can i convert
it into this format of json
"PublishedTo":"\/Date(1432645752000+0200)\/"
I got the following date input Sat May 23 18:09:05 EEST 2015 ,
how can i convert
it into this format of json
"PublishedTo":"\/Date(1432645752000+0200)\/"
Try this:
String givenDateString = "5/28/2015";
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
try {
Date mDate = sdf.parse(givenDateString);
long timeInMilliseconds = mDate.getTime();
System.out.println("Date in milli :: " + timeInMilliseconds);
} catch (ParseException e) {
e.printStackTrace();
}
The seems like the date/time wire format used in WCF. From MSDN it states:
DateTime values appear as JSON strings in the form of "/Date(700000+0500)/", where the first number (700000 in the example provided) is the number of milliseconds in the GMT time zone, regular (non-daylight savings) time since midnight, January 1, 1970. The number may be negative to represent earlier times. The part that consists of "+0500" in the example is optional and indicates that the time is of the Local kind - that is, should be converted to the local time zone on deserialization. If it is absent, the time is deserialized as Utc. The actual number ("0500" in this example) and its sign (+ or -) are ignored.
If so, this issue has been discussed several times on SO.
POSTing a DateTime from Android to a WCF RESTful JSON Service