Usage of Java date and time types in HTDS

You have a ruleset based on a Java XOM model that contains some fields with date and time types from the Java SE 8 java.time package (also known as JSR 310). You must annotate your Java XOM model for the date and time types if you plan to execute SOAP, REST XML, and REST JSON requests or generate sample requests with a hosted transparent decision service (HTDS).

Tip: If you execute requests by using REST JSON only and you do not generate sample requests, then annotating your Java XOM model is not necessary.

You must reference XML adapter classes first to annotate your Java XOM model, since you need the XML adapter classes to compile the Java XOM classes. You can find the XML adapter classes in the <installDir>/executionserver/lib/jaxb-jsr310-support-1.1.3-IBM.jar file. You do not need to deploy this jar file in the managed XOM repository.

The following table shows the XML adapter classes and corresponding supported Java date and time types:
Table 1. XML adapter classes and corresponding supported Java date and time types
XML adapter class Java type
com.ibm.jaxb.adapter.jsr310.DurationXmlAdapter java.time.Duration
com.ibm.jaxb.adapter.jsr310.InstantXmlAdapter java.time.Instant
com.ibm.jaxb.adapter.jsr310.LocalDateTimeXmlAdapter java.time.LocalDateTime
com.ibm.jaxb.adapter.jsr310.LocalDateXmlAdapter java.time.LocalDate
com.ibm.jaxb.adapter.jsr310.LocalTimeXmlAdapter java.time.LocalTime
com.ibm.jaxb.adapter.jsr310.MonthDayXmlAdapter java.time.MonthDay
com.ibm.jaxb.adapter.jsr310.OffsetDateTimeXmlAdapter java.time.OffsetDateTime
com.ibm.jaxb.adapter.jsr310.OffsetTimeXmlAdapter java.time.OffsetTime
com.ibm.jaxb.adapter.jsr310.PeriodXmlAdapter java.time.Period
com.ibm.jaxb.adapter.jsr310.YearMonthXmlAdapter java.time.YearMonth
com.ibm.jaxb.adapter.jsr310.YearXmlAdapter java.time.Year
com.ibm.jaxb.adapter.jsr310.ZonedDateTimeXmlAdapter java.time.ZonedDateTime
com.ibm.jaxb.adapter.jsr310.ZoneIdXmlAdapter java.time.ZoneId
com.ibm.jaxb.adapter.jsr310.ZoneIdXmlAdapter java.time.ZoneOffset
The following example shows how you can annotate at the package level (package-info.java):
@XmlJavaTypeAdapters({
    @XmlJavaTypeAdapter(value=DurationXmlAdapter.class, type=Duration.class),
    @XmlJavaTypeAdapter(value=LocalDateTimeXmlAdapter.class, type=LocalDateTime.class),
    @XmlJavaTypeAdapter(value=ZonedDateTimeXmlAdapter.class, type=ZonedDateTime.class)
})

package com.acme.samplexom;

import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import com.ibm.jaxb.adapter.jsr310.DurationXmlAdapter;
import com.ibm.jaxb.adapter.jsr310.LocalDateTimeXmlAdapter;
import com.ibm.jaxb.adapter.jsr310.ZonedDateTimeXmlAdapter;
The following example shows how you can annotate at the attribute level:
package com.acme.samplexom;

import java.time.ZonedDateTime;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.ibm.jaxb.adapter.jsr310.ZonedDateTimeXmlAdapter;

public class Item {
	@XmlJavaTypeAdapter(value=ZonedDateTimeXmlAdapter.class)
	private ZonedDateTime dateInfo;
	
	public ZonedDateTime getDateInfo(){
		return dateInfo;
	}
...
}
Restriction:

Sample values for the java.time types are not displayed when you generate sample requests with HTDS. You can see empty tags or tags containing string in the XML format and null values in the JSON format.

However, the standard textual representations are displayed at run time; for example, P3M for java.time.Period to represent a 3-month period, and 2007-12 for java.time.YearMonth to represent December 2007.