Open Tomas-Kraus opened 10 years ago
@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:
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.
JAXB spec should be updated to support new JDK8 Date/Time apis