Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jaxb DateTime without timezone

I'm trying to map a xml DateTime element using jaxb so that it does not care about timezone information at all. Either by rejecting the input, or by treating it as server default timezone. e.g.

<dateTime>2011-01-01T06:00:00-04:00:00</dateTime>  

would be treated the same as

<dateTime>2011-01-01T06:00:00</dateTime>

Right now GregorianCalendar automatically converts any dateTime with timezone information to GregorianCalendar object, so I don't know what the original input was. Can anyone shine some light on this? I'm open to use other dateTime types other than GregorianCalendar too, is there a graceful way to use org.joda.time.DateTime object with jaxb/xml maybe?

Thanks in advance.

like image 309
BZapper Avatar asked Jun 20 '11 22:06

BZapper


1 Answers

There is a useful post on Joda and JAXB from Blaise Doughan using an @XmlJavaTypeAdapter which you should be able to use to convert the time format.

like image 200
andyb Avatar answered Sep 29 '22 12:09

andyb