StringToLocalDateTime extends StringToString { @Override public Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding) { String value = (String)super.to(bytes, offset, length, decimals, removePadding); if(value != null && !value.isEmpty()) { return LocalDateTime.parse(value, formatter); } else { return null; } }  @Override void initialize(TypeConverterConfig config); @Override void validate(Class<?> type, int size, int decimals); @Override Object to(byte[] bytes, int offset, int length, int decimals, boolean removePadding); @Override byte[] from(Object value, int length, int decimals, boolean addPadding);  }
@Test public void testTo() throws Exception { assertEquals(LocalDateTime.parse("2015-08-04T10:11:30"), typeConverter.to("20150804101130".getBytes(StandardCharsets.UTF_8), 0, 14, -1, true)); assertEquals(LocalDateTime.parse("2015-08-04T10:11:30"), typeConverter.to("0020150804101130".getBytes(StandardCharsets.UTF_8), 0, 16, -1, true)); }
@Test public void testToZeroValue() throws Exception { assertEquals(null, typeConverter.to("00000000000000".getBytes(StandardCharsets.UTF_8), 0, 14, -1, true)); }