Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JAXB and xsd:date formatting

843834Jan 14 2003 — edited Mar 27 2003
I have a simpleType defining a date with a pattern restriction. The jaxb compiler creates a setter method that expects a Calendar object. How dose on create a Calendar object of s specific format.
The schema fragment is as follows:

<xsd:simpleType name="LocalDateType">
<xsd:restriction base="xsd:date">
<xsd:pattern value="\d\d\d\d-\d\d-\d\d"/>
</xsd:restriction>
</xsd:simpleType>

Calendar rightNow = Calendar.getInstance(); returns: 2003-01-14-05:00

How do I get rid of the '-05:00' but maintain it as a Calendar object?

Using SimpleDateFormatter leaves you with a string:

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-dd-mm");
formattedRightNow = formatter.format(today); //formattedRightNow is a String
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2003
Added on Jan 14 2003
3 comments
176 views