View Javadoc
1   package org.djunits.demo.examples;
2   
3   import org.djunits.unit.LengthUnit;
4   import org.djunits.value.Scalar;
5   import org.djunits.value.vdouble.scalar.Length;
6   import org.djunits.value.vfloat.scalar.FloatLength;
7   
8   /**
9    * Parsing.java. <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 Parsing
17  {
18      public static void main(String[] args)
19      {
20          Length l = new Length(100.0, LengthUnit.KILOMETER);
21          System.out.println(Scalar.stringOf(l));
22          System.out.println(Length.valueOf(Scalar.stringOf(l)));
23  
24          String[] sa = new String[] {"80 mm", "+80 mm", "80.0 mm", "-80.00mm", "8E6mm", "-8E-3yd", "8.mm", "0m",
25                  "18.37823472346234623  mi"};
26          for (String s : sa)
27          {
28              System.out.println("\n" + Length.valueOf(s));
29              System.out.println(Scalar.stringOf(Length.valueOf(s)));
30          }
31  
32          System.out.println("\n==========================================================\n");
33          
34          FloatLength fl = new FloatLength(100.0f, LengthUnit.KILOMETER);
35          System.out.println(Scalar.stringOf(fl));
36          System.out.println(FloatLength.valueOf(Scalar.stringOf(fl)));
37  
38          for (String s : sa)
39          {
40              System.out.println("\n" + FloatLength.valueOf(s));
41              System.out.println(Scalar.stringOf(FloatLength.valueOf(s)));
42          }
43  
44      }
45  
46  }
47