jaxb-api icon indicating copy to clipboard operation
jaxb-api copied to clipboard

JAXB spec should be updated to support new JDK8 Date/Time apis

Open Tomas-Kraus opened this issue 10 years ago • 7 comments

JAXB spec should be updated to support new JDK8 Date/Time apis

Tomas-Kraus avatar Apr 01 '14 07:04 Tomas-Kraus

  • Issue Imported From: https://github.com/javaee/jaxb-v2/issues/1009
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @glassfishrobot

Tomas-Kraus avatar Sep 21 '18 16:09 Tomas-Kraus

@glassfishrobot Commented Reported by snajper

Tomas-Kraus avatar Apr 01 '14 07:04 Tomas-Kraus

@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

Tomas-Kraus avatar Sep 28 '15 08:09 Tomas-Kraus

@glassfishrobot Commented Was assigned to yaroska

Tomas-Kraus avatar Apr 01 '14 07:04 Tomas-Kraus

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-1009

Tomas-Kraus avatar Apr 24 '17 12:04 Tomas-Kraus

@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.

antoniosanct avatar Nov 13 '23 01:11 antoniosanct

@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.

antoniosanct avatar Apr 18 '24 22:04 antoniosanct