jaxb-api
jaxb-api copied to clipboard
JAXB spec should be updated to support new JDK8 Date/Time apis
JAXB spec should be updated to support new JDK8 Date/Time apis
- Issue Imported From: https://github.com/javaee/jaxb-v2/issues/1009
- Original Issue Raised By:@glassfishrobot
- Original Issue Assigned To: @glassfishrobot
@glassfishrobot Commented Reported by snajper
@glassfishrobot Commented puce said: There should be helper classes to make customization as simple as for java.util.Calendar:
https://jaxb.java.net/guide/Using_different_datatypes.html
https://docs.oracle.com/javase/8/docs/api/javax/xml/bind/DatatypeConverter.html
@glassfishrobot Commented Was assigned to yaroska
@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-1009
@lukasj The proper link mentions the use of an adapter class when it really makes use of java.util.Date instead of java.util.Calendar:
https://eclipse-ee4j.github.io/jaxb-ri/4.0.3/docs/ch03.html#customization-of-schema-compilation-using-different-datatypes
Is it necessary to modify API to include the "new" JSR-310?
package org.acme.foo;
public class ZonedDateTimeAdapter {
public static ZonedDateTime parseDate(String s) {
return DatatypeConverter.parseDate(s).toZonedDateTime();
}
public static String printDate(ZonedDateTime zdt) {
Calendar cal = new GregorianCalendar();
cal.setTime(java.util.Date.from(zdt.toInstant()));
return DatatypeConverter.printDate(cal);
}
}
In fact, DatatypeFactory doesn't extend JSR-310 API.
Regards, Antonio.
@lukasj What do you think about replacing Calendar to ZonedDateTime? Would it be in a future 4.1 release because of break backward-compatibility?
Regards, Antonio.