java - Jackson JSON - Strip Timezone from Calendar object while deserializing -


i have jackson deserializer convert date in json string calendar object. passing "2015-10-22" in request , gets converted "2015-10-22-04:00" after convert calendar object. there way suppress timezone being sent? in scenarios use xmlgregoriancalendar , using "date.settimezone(datatypeconstants.field_undefined)" suppress timezone.

private static simpledateformat formatter = new simpledateformat("yyyy-mm-dd");  @override public calendar deserialize(jsonparser jsonparser, deserializationcontext arg1) throws ioexception, jsonprocessingexception {     // todo auto-generated method stub     string datestring = jsonparser.gettext();     try {          calendar calendar = calendar.getinstance();         calendar.settime(formatter.parse(datestring));         return calendar;     } catch (parseexception e) {         throw new runtimeexception(e);     } } 

no timezone sent, question "is there way suppress timezone being sent?" meaningless.

the calendar.getinstance() method assigns default timezone, see javadoc:

gets calendar using default time zone , locale. calendar returned based on current time in default time zone default locale.

you replace "current time" call settime(), time zone , locale remain unchanged.

a calendar object always have time zone , locale.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -