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