jakartaee / jaxb-api

BSD 3-Clause "New" or "Revised" License
61 stars 42 forks source link

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

Open Tomas-Kraus opened 10 years ago

Tomas-Kraus commented 10 years ago

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

Tomas-Kraus commented 6 years ago
Tomas-Kraus commented 10 years ago

@glassfishrobot Commented Reported by snajper

Tomas-Kraus commented 9 years ago

@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 commented 10 years ago

@glassfishrobot Commented Was assigned to yaroska

Tomas-Kraus commented 7 years ago

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

antoniosanct commented 1 year ago

@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 commented 7 months ago

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