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