### Question:
TimeField implements FieldType<Time> { @Override public Time convert(Object objValue) throws OperationException { if (objValue == null) { throw new OperationException(ErrorCode.DATATYPE_MISMATCH); } if (objValue instanceof String) { try { return Time.valueOf(objValue.toString()); } catch (IllegalArgumentException ex) { throw new OperationException(ErrorCode.INVALID_TIME_FORMAT, "The string " + objValue.toString() + " could not be recongized as a valid time format. Supported format is hh:mm:ss"); } } if (objValue instanceof Long) { return new Time((Long) objValue); } if (objValue instanceof Time) { return (Time) objValue; } throw new OperationException(ErrorCode.DATATYPE_MISMATCH, "Could not convert " + objValue + " to a valid time type"); } TimeField();  TimeField(final Time defaultValue);  TimeField(final boolean withTimeZone);  TimeField(final boolean withTimeZone, final Time defaultValue); @Override Types getType(); boolean isWithTimeZone(); @Override Time getDefaultValue(); @Override boolean hasDefaultValue(); @Override Time convert(Object objValue); @Override JSONObject toJson();  }### Answer:
@Test public void testConvert() throws Exception { System.out.println("convert"); TimeField instance = new TimeField(); assertEquals(Time.valueOf("12:34:56"), instance.convert("12:34:56")); assertEquals(Time.valueOf("12:34:56"), instance.convert(Time.valueOf("12:34:56"))); assertEquals(Time.valueOf("12:34:56"), instance.convert(Time.valueOf("12:34:56").getTime())); assertEquals(Time.valueOf("23:34:56"), instance.convert(Time.valueOf("23:34:56").getTime())); assertEquals(Time.valueOf("23:04:56"), instance.convert(Time.valueOf("23:4:56").getTime())); assertEquals(Time.valueOf("23:04:05"), instance.convert(Time.valueOf("23:4:5").getTime())); final long currentTime = System.currentTimeMillis(); assertEquals(new Time(currentTime), instance.convert(currentTime)); assertEquals(new Time(-1), instance.convert((long)-1)); try { instance.convert("12-34-56"); fail("Accepted incorrect time value without reporting exception"); } catch (OperationException ex) { assertEquals(ErrorCode.INVALID_TIME_FORMAT, ex.getErrorCode()); } try { instance.convert(null); fail("null value not checked"); } catch (OperationException ex) { assertEquals(ErrorCode.DATATYPE_MISMATCH, ex.getErrorCode()); } try { instance.convert(new Integer(0)); fail("Accepted incorrect data type of Integer"); } catch (OperationException ex) { assertEquals(ErrorCode.DATATYPE_MISMATCH, ex.getErrorCode()); } }