use of org.simpleflatmapper.map.property.time.JavaDateTimeFormatterProperty in project SimpleFlatMapper by arnaudroger.
the class PropertyTest method testJavaDateTimeFormatterProperty.
@Test
public void testJavaDateTimeFormatterProperty() {
JavaDateTimeFormatterProperty property = new JavaDateTimeFormatterProperty(DateTimeFormatter.ISO_DATE);
assertSame(DateTimeFormatter.ISO_DATE, property.get());
assertEquals("DateTimeFormatter{" + DateTimeFormatter.ISO_DATE + "}", property.toString());
}
use of org.simpleflatmapper.map.property.time.JavaDateTimeFormatterProperty in project SimpleFlatMapper by arnaudroger.
the class CellValueReaderFactoryImplTest method testJavaLocalDateTimeWithDateTimeFormatter.
@Test
public void testJavaLocalDateTimeWithDateTimeFormatter() throws Exception {
String date = "20150128 12:03:56";
final DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm:ss");
java.time.LocalDateTime localTime = java.time.LocalDateTime.parse(date, yyyyMMdd);
CellValueReader<?> reader = cellValueReaderFactory.getReader(java.time.LocalDateTime.class, 0, CsvColumnDefinition.IDENTITY.add(new JavaDateTimeFormatterProperty(yyyyMMdd)), null);
assertEquals(localTime, reader.read(date.toCharArray(), 0, date.length(), null));
}
use of org.simpleflatmapper.map.property.time.JavaDateTimeFormatterProperty in project SimpleFlatMapper by arnaudroger.
the class FieldMapperToAppendableFactoryJavaTimeTest method testLocalDateTimeWithFormaterAppender.
@Test
public void testLocalDateTimeWithFormaterAppender() throws Exception {
MappingContextFactoryBuilder<JavaTimeObject, CsvColumnKey> builder = getMappingContextBuilder();
FieldMapper<JavaTimeObject, Appendable> fieldMapper = defaultFieldAppenderFactory.newFieldMapper(newPropertyMapping("localDateTime", javaTimeObjectClassMeta, FieldMapperColumnDefinition.<CsvColumnKey>identity().add(new JavaDateTimeFormatterProperty(DateTimeFormatter.ofPattern("dd/MM/yyyy")))), builder, null);
testFieldMapper("03/12/2011", fieldMapper, javaTimeObject, builder.newFactory());
}
Aggregations