com.migesok.jaxb.adapter.javatime.ZoneIdXmlAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaxb-java-time-adapters Show documentation
Show all versions of jaxb-java-time-adapters Show documentation
JAXB adapters for Java 8 Date and Time API (JSR-310) types
The newest version!
package com.migesok.jaxb.adapter.javatime;
import java.time.ZoneId;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
* {@code XmlAdapter} mapping JSR-310 {@code ZoneId} and {@code ZoneOffset} to the time-zone ID string
*
* Time-zone ID format details:
*
* - {@link java.time.ZoneId#of(java.lang.String)}
* - {@link java.time.ZoneId#getId()}
*
*
* @see javax.xml.bind.annotation.adapters.XmlAdapter
* @see java.time.ZoneId
* @see java.time.ZoneOffset
*/
public class ZoneIdXmlAdapter extends XmlAdapter {
@Override
public ZoneId unmarshal(String stringValue) {
return stringValue != null ? ZoneId.of(stringValue) : null;
}
@Override
public String marshal(ZoneId value) {
return value != null ? value.getId() : null;
}
}