Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jaxb, marshalling, and java.util.calendar

 
shen mistryl
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an issue with how a calendar is being marshalled into xml. I'm VERY new to jaxb, so my apologies if this is a stupid question.

One of the objects I am marshalling has some fields that take a calendar object in the setters to set a data and a time.
When the jaxb objects are mashalled into XML, the elements that come from the calendar are in this format:

<CmdDate>2005-07-06-07:00</CmdDate>
<CmdTime>12:24:10.995-07:00</CmdTime>

Is there something I can set on the Calendar or on the Marshaller so that the offset (-07:00) is not used when marshalling the XML?
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing that Calendar.setTimeZone might help, before you do the POJO-XML conversion.

To remove a timezone, you basically want to set the timezone to GMT+0, I think. You can get a GMT+0 timezone like this:



You'll probably get a better response in the XML and Related Technologies forum.

On a side note, remember that if you're logging statements including dates, then you'll also need to set the timezone of the DateFormat you use (to format the date for logging). This confused me for a while.


-Tim
[ July 06, 2005: Message edited by: Tim West ]
 
shen mistryl
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestion...unfortunately it just changes it to +0:00... I'll try the XMl forum like you suggested.
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK - In this case, it's being caused by the particular type in the schema - XML Schema supports something like 8 different ways of specifying date/time. (I forget the exact figure).

So I'd guess that you'll have to bind the Java object to a different time-type - one which doesn't use timezone. I've never tried to do this, mind.

In the short term, couldn't you just ignore the timezone bit? That's ugly, I know - but it would work.

Sorry I couldn't help more!


-Tim
 
Don't touch me. And dont' touch this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!