![JAR search and dependency download from the Maven repository](/logo.png)
io.github.threetenjaxb.core.YearXmlAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of threeten-jaxb-core Show documentation
Show all versions of threeten-jaxb-core Show documentation
JAXB adapters for Java 8 Date and Time API (JSR-310) types
The newest version!
package io.github.threetenjaxb.core;
import java.time.Year;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
/**
* {@code XmlAdapter} mapping JSR-310 {@code Year} to ISO proleptic year number
*
* Year number interpretation details:
*
* - {@link java.time.Year#of(int)}
* - {@link java.time.Year#getValue()}
*
*
* Be aware that using this adapter will yield {@code null} when unmarshalling
* {@code xsd:gYear} types. Use {@link YearAsTextXmlAdapter} instead.
*
* @see jakarta.xml.bind.annotation.adapters.XmlAdapter
* @see java.time.Year
*/
public class YearXmlAdapter extends XmlAdapter {
@Override
public Year unmarshal(Integer isoYearInt) {
return isoYearInt != null ? Year.of(isoYearInt) : null;
}
@Override
public Integer marshal(Year year) {
return year != null ? year.getValue() : null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy