![JAR search and dependency download from the Maven repository](/logo.png)
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
package com.migesok.jaxb.adapter.javatime;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.time.Duration;
/**
* {@link javax.xml.bind.annotation.adapters.XmlAdapter XmlAdapter} mapping JSR-310
* {@link java.time.Duration Duration} to ISO-8601 string
*
* String format details:
* {@link java.time.Duration#parse(java.lang.CharSequence)}
* {@link java.time.Duration#toString()}
*
* @author Mikhail Sokolov
*/
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;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy