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!

Format XMLGregorianCalendar

843834Jul 10 2008 — edited Jul 24 2008
Hello,

when I'll create a XML-document with JAXP, then the Jax-Parser format any date, that I'll use, in the Format
yyyy-mm-ddTimezone (for Example: 2008-01-09+01:00), when I'm using this function:
protected XMLGregorianCalendar getDate(java.util.Date date) {
	try {
            if (date == null) return null ;
            GregorianCalendar cal = new GregorianCalendar() ;
            cal.setTime(date) ;
     return DatatypeFactory.newInstance().newXMLGregorianCalendar(cal) ;
	} catch (DatatypeConfigurationException e) {
	    throw new java.lang.Error(e);
	}
    }
but the format of the date should be like YYY-MM-DD without any information about the timezone (and without timestamp).
I'm using JAXP, so I think, i can't use the "normally" Class java.util.Date with the "normaly" formats?
Can anybody tell, how to format the date without the timezone?

Thanks
Jens Hirsch

Edited by: JonnyD. on 10.07.2008 11:06
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 21 2008
Added on Jul 10 2008
4 comments
1,824 views