![JAR search and dependency download from the Maven repository](/logo.png)
io.github.threetenjaxb.core.YearAsTextXmlAdapter 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 jakarta.xml.bind.annotation.adapters.XmlAdapter;
import java.time.Year;
/**
* {@code XmlAdapter} mapping JSR-310 {@code Year} to ISO proleptic year string
*
* Year string interpretation details:
*
* - {@link Year#parse(CharSequence)}
* - {@link Year#toString()}
*
*
* This adapter is suitable for {@code xsd:gYear} types.
*
* @see XmlAdapter
* @see Year
*/
public class YearAsTextXmlAdapter extends XmlAdapter {
@Override
public Year unmarshal(String isoYearString) {
return isoYearString != null ? Year.parse(isoYearString) : null;
}
@Override
public String marshal(Year year) {
return year != null ? year.toString() : null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy