com.migesok.jaxb.adapter.javatime.YearMonthXmlAdapter 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.YearMonth;
import javax.xml.bind.annotation.adapters.XmlAdapter;
/**
* {@code XmlAdapter} mapping JSR-310 {@code YearMonth} to a string such as 2007-12
*
* String format details:
*
* - {@link java.time.YearMonth#parse(java.lang.CharSequence)}
* - {@link java.time.YearMonth#toString()}
*
*
* @see javax.xml.bind.annotation.adapters.XmlAdapter
* @see java.time.YearMonth
*/
public class YearMonthXmlAdapter extends XmlAdapter {
@Override
public YearMonth unmarshal(String stringValue) {
return stringValue != null ? YearMonth.parse(stringValue) : null;
}
@Override
public String marshal(YearMonth value) {
return value != null ? value.toString() : null;
}
}