1 package org.opentrafficsim.xml.bindings;
2
3 import org.djunits.value.vdouble.scalar.Duration;
4 import org.djutils.logger.CategoryLogger;
5 import org.opentrafficsim.xml.bindings.types.DurationType;
6
7
8
9
10
11
12
13
14
15
16 public class DurationAdapter extends ScalarAdapter<Duration, DurationType>
17 {
18
19
20 @Override
21 public DurationType unmarshal(final String field)
22 {
23 if (isExpression(field))
24 {
25 return new DurationType(trimBrackets(field));
26 }
27 try
28 {
29 return new DurationType(Duration.valueOf(field));
30 }
31 catch (Exception exception)
32 {
33 CategoryLogger.always().error(exception, "Problem parsing Duration '" + field + "'");
34 throw exception;
35 }
36 }
37
38 }