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

Discussion in 'Java' started by Sébastien de Mapias, Sep 9, 2008.

  1. 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
     
    Sébastien de Mapias, Sep 9, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q3liZXJMb3R1cw==?=

    Does CompareValidator work for the date in dd-mmm-yyyy format?

    =?Utf-8?B?Q3liZXJMb3R1cw==?=, Jun 10, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    15,923
    Peter Blum
    Jun 10, 2005
  2. Chu
    Replies:
    3
    Views:
    4,233
    Shawn
    Aug 15, 2006
  3. Ashraf Ansari

    convert MM/dd/yyyy format into dd/MM/yyyy

    Ashraf Ansari, Aug 30, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    803
    Alexey Smirnov
    Aug 30, 2007
  4. Gilles Ganault

    Converting DD MM YYYY into YYYY-MM-DD?

    Gilles Ganault, Aug 17, 2009, in forum: Python
    Replies:
    18
    Views:
    1,414
    Mark Tolonen
    Aug 20, 2009
  5. J P Singh
    Replies:
    4
    Views:
    298
    J P Singh
    Feb 10, 2004
Loading...

Share This Page