XSD date displayed as YYYY-MM-DD+HH-MN: possible to improve format ?

  • Thread starter Sébastien de Mapias
  • Start date
S

Sébastien de Mapias

Hi,

I'm retrieving birthdates from an Oracle DB table, the column type
is DATE.
select to_char(birthdate,'dd/mm/yyyy hh24:mi.ss') from PERSONS
where id = 2 returns the following:
~ 01/01/1968 00:00.00
(so the date is truncated to its midnight value)

In my code I do at some point the following (when I map my persistent
objects to the protocol definition) :
~ protocolPerson.setBirthdate(persistPerson.getBirthdate());
(in this case the type is java.util.Calendar)

In my protocol's xsd, the birthdate is defined as:
~ <xs:element name="birthdate" type="xs:date" minOccurs="0"/>

The problem is that once my XML is processed and displayed, I get
~ <birthdate>1968-01-01+01:00</birthdate>
in my response message.

I added the following in XJB file, to tell the marshaller that the
XSD date type is a java.util.Calendar:
~ <jxb:javaType name="java.util.Calendar" xmlType="xs:date"
~ parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
~ printMethod="javax.xml.bind.DatatypeConverter.printDate" />

I'd like to get "<birthdate>1968-01-01</birthdate>", or even better
"<birthdate>01/01/1968</birthdate>".

Is there an easy way to format this output (by playing with the XJB
configuration only maybe) ?

Thanks a lot.
Regards,
Sébastien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top