| Constructor and Description |
|---|
JSONs() |
| Modifier and Type | Method and Description |
|---|---|
static String |
d2j(Date d)
Marshalls a Date object to a string, such that it can be add
to
JSONArray or JSONObject (a.k.a., JSON-ize). |
static Date |
j2d(String s)
Unmarshalls a string to a date.
|
public static final String d2j(Date d)
JSONArray or JSONObject (a.k.a., JSON-ize).
It is used with j2d(java.lang.String). d2j(java.util.Date) is used to JSON-ize a Date
object, while j2d(java.lang.String) is to unmarshall it back to a Date object.
Notice it assumes TimeZones.getCurrent() (and Locale-independent).
However, the result string has no time zone information. Thus,
if the client is in different time zone, the date object will be different.
However, since the object will be marshalled back in the same way,
the value sent back from the client will be the same (regardless
the time zone is different).
public static final Date j2d(String s) throws ParseException
d2j(java.util.Date). d2j(java.util.Date) is used to JSON-ize a Date
object, while j2d(java.lang.String) is to unmarshall it back to a Date object.
Notice it assumes TimeZones.getCurrent() (and Locale-independent).
ParseExceptionCopyright © 2018. All rights reserved.