As Yoni already mentioned, JSON does not define what a date is, or how to serialize one. Looking at the JSON snippet you posted, it looks as if someone felt a little too creative, serializing a date like that.
The important thing to note here is: to any JSON parser, this is just a string. The "Date(12345)" part is meaningless. You have to parse that yourself into a java.util.Date
, which in that case means stripping off anything that's not a number, and using the number (the UNIX time) to instantiate a java.util.Date
.
Just for the record. A typical way to pass a date using JSON would be either
{'timestamp':1265231402}
or more likely
{'timestamp':'Wed, 03 Feb 2010 22:10:38 +0100'}
The latter example would be the current timestamp (as I'm writing this) using standard RFC-2822 formatting, which can easily be parsed using Java's date utilities. Have a look at SimpleDateFormat for how to parse dates in Java.