1 package org.opentrafficsim.xml.bindings;
2
3 import javax.xml.bind.annotation.adapters.XmlAdapter;
4
5 import org.djunits.value.Scalar;
6 import org.djunits.value.vdouble.scalar.Duration;
7
8 /**
9 * DurationAdapter converts between the XML String for a Duration and the DJUnits Duration. <br>
10 * <br>
11 * Copyright (c) 2003-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
12 * for project information <a href="https://www.simulation.tudelft.nl/" target="_blank">www.simulation.tudelft.nl</a>. The
13 * source code and binary code of this software is proprietary information of Delft University of Technology.
14 * @author <a href="https://www.tudelft.nl/averbraeck" target="_blank">Alexander Verbraeck</a>
15 */
16 public class DurationAdapter extends XmlAdapter<String, Duration>
17 {
18 /** {@inheritDoc} */
19 @Override
20 public Duration unmarshal(final String field) throws IllegalArgumentException
21 {
22 return Duration.valueOf(field);
23 }
24
25 /** {@inheritDoc} */
26 @Override
27 public String marshal(final Duration duration) throws IllegalArgumentException
28 {
29 return Scalar.textualStringOfDefaultLocale(duration);
30 }
31
32 }