Search in sources :

Example 1 with JavaDateTimeFormatterProperty

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());
}
Also used : JavaDateTimeFormatterProperty(org.simpleflatmapper.map.property.time.JavaDateTimeFormatterProperty) Test(org.junit.Test)

Example 2 with JavaDateTimeFormatterProperty

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));
}
Also used : JavaDateTimeFormatterProperty(org.simpleflatmapper.map.property.time.JavaDateTimeFormatterProperty) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.junit.Test)

Example 3 with JavaDateTimeFormatterProperty

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());
}
Also used : CsvColumnKey(org.simpleflatmapper.csv.CsvColumnKey) JavaDateTimeFormatterProperty(org.simpleflatmapper.map.property.time.JavaDateTimeFormatterProperty) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 JavaDateTimeFormatterProperty (org.simpleflatmapper.map.property.time.JavaDateTimeFormatterProperty)3 DateTimeFormatter (java.time.format.DateTimeFormatter)1 CsvColumnKey (org.simpleflatmapper.csv.CsvColumnKey)1