Search in sources :

Example 6 with JavaZoneIdProperty

use of org.simpleflatmapper.map.property.time.JavaZoneIdProperty in project SimpleFlatMapper by arnaudroger.

the class PreparedStatementFieldMapperFactoryTest method testJavaLocalDate.

@Test
public void testJavaLocalDate() throws Exception {
    java.time.LocalDate value = java.time.LocalDate.now();
    java.time.ZoneId zoneId = ZoneId.of("America/Los_Angeles");
    newFieldMapperAndMapToPS(new ConstantGetter<Object, java.time.LocalDate>(value), java.time.LocalDate.class, new JavaZoneIdProperty(zoneId));
    newFieldMapperAndMapToPS(NullGetter.<Object, java.time.LocalDate>getter(), java.time.LocalDate.class);
    verify(ps).setDate(1, new java.sql.Date(value.atStartOfDay(zoneId).toInstant().toEpochMilli()));
    verify(ps).setNull(2, Types.DATE);
}
Also used : LocalDate(java.time.LocalDate) DbObject(org.simpleflatmapper.test.beans.DbObject) JavaZoneIdProperty(org.simpleflatmapper.map.property.time.JavaZoneIdProperty) LocalDate(java.time.LocalDate) ZoneId(java.time.ZoneId) java.sql(java.sql) Test(org.junit.Test) ResultSetGetterFactoryTest(org.simpleflatmapper.jdbc.test.impl.getter.ResultSetGetterFactoryTest)

Example 7 with JavaZoneIdProperty

use of org.simpleflatmapper.map.property.time.JavaZoneIdProperty in project SimpleFlatMapper by arnaudroger.

the class PropertyTest method testJavaZoneIdProperty.

// IFJAVA8_START
@Test
public void testJavaZoneIdProperty() {
    ZoneId zoneId = ZoneId.of("UTC");
    JavaZoneIdProperty property = new JavaZoneIdProperty(zoneId);
    assertSame(zoneId, property.get());
    assertEquals("ZoneId{UTC}", property.toString());
}
Also used : ZoneId(java.time.ZoneId) JavaZoneIdProperty(org.simpleflatmapper.map.property.time.JavaZoneIdProperty) Test(org.junit.Test)

Aggregations

ZoneId (java.time.ZoneId)7 Test (org.junit.Test)7 JavaZoneIdProperty (org.simpleflatmapper.map.property.time.JavaZoneIdProperty)7 ResultSetGetterFactoryTest (org.simpleflatmapper.jdbc.test.impl.getter.ResultSetGetterFactoryTest)5 DbObject (org.simpleflatmapper.test.beans.DbObject)5 java.sql (java.sql)3 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1