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