io.github.threetenjaxb.core.MonthXmlAdapter 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.Month;
/**
* {@code XmlAdapter} mapping JSR-310 {@code Month} to ISO proleptic month number
*
* Month number interpretation details:
*
* - {@link java.time.Month#of(int)}
* - {@link java.time.Month#getValue()}
*
*
* Be aware that using this adapter will yield {@code null} when unmarshalling
* {@code xsd:gMonth} types. Use {@link MonthAsTextXmlAdapter} instead.
*
* @see jakarta.xml.bind.annotation.adapters.XmlAdapter
* @see java.time.Month
*/
public class MonthXmlAdapter extends XmlAdapter {
@Override
public Month unmarshal(Integer intValue) {
return intValue != null ? Month.of(intValue) : null;
}
@Override
public Integer marshal(Month value) {
return value != null ? value.getValue() : null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy