![JAR search and dependency download from the Maven repository](/logo.png)
io.github.threetenjaxb.core.MonthAsTextXmlAdapter 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 string
*
* Month string interpretation details (transformed to a string):
*
* - {@link java.time.Month#of(int)}
* - {@link java.time.Month#getValue()}
*
*
* This adapter is suitable for {@code xsd:gMonth} types.
*
* @see jakarta.xml.bind.annotation.adapters.XmlAdapter
* @see java.time.Month
*/
public class MonthAsTextXmlAdapter extends XmlAdapter {
@Override
public Month unmarshal(String stringValue) {
return stringValue != null ? Month.of(Integer.parseInt(stringValue)) : null;
}
@Override
public String marshal(Month value) {
return value != null ? Integer.toString(value.getValue()) : null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy