Code example for SimpleDateFormat

Methods: parseObject

0
 
  public void testConvertValue_time() throws Exception { 
    ParameterDefinition string;
    string = new ParameterDefinition("Test", "java.sql.Time", false, null);
    String value = "10:11:12";
    DateFormat df = new SimpleDateFormat("HH:mm:ss");
    Date time = (Date) df.parseObject(value);
    Time timeConverted = (Time) string.convertValue(value);
    assertEquals(new Time(time.getTime()), timeConverted);
  } 
 
  public void testConvertValue_boolean() throws Exception { 
    ParameterDefinition string;
    string = new ParameterDefinition("Test", "java.lang.Boolean", false, null);
    assertTrue((Boolean) string.convertValue("true"));
    assertFalse((Boolean) string.convertValue("false"));
  } 
} 
 
Connect your IDE to all the code out there  Get Codota for Java