public static DateTimeValue now( Clock clock, Supplier<ZoneId> defaultZone ) { return now( clock.withZone( defaultZone.get() ) ); }
public static DateTimeValue now( Clock clock, String timezone ) { return now( clock.withZone( parseZoneName( timezone ) ) ); }
@Test @FrozenClockRule.TimeZone( "Europe/Stockholm" ) public void shouldAcquireCurrentDateTime() { assertEqualTemporal( datetime( ZonedDateTime.now( clock ) ), DateTimeValue.now( clock ) ); assertEqualTemporal( // Using the named UTC timezone datetime( ZonedDateTime.now( clock.withZone( "UTC" ) ) ), DateTimeValue.now( clock, "UTC" ) ); assertEqualTemporal( // Using the timezone defined as 0 hours offset from UTC datetime( ZonedDateTime.now( clock.withZone( UTC ) ) ), DateTimeValue.now( clock, "Z" ) ); }
@Test public void testMetaDate() throws Exception { Map<String, Object> param = map( "DATE", DateValue.now(Clock.systemDefaultZone()), "LOCAL_DATE", LocalDateTimeValue.now(Clock.systemDefaultZone()), "TIME", TimeValue.now(Clock.systemDefaultZone()), "LOCAL_TIME", LocalTimeValue.now(Clock.systemDefaultZone()), "DATE_TIME", DateTimeValue.now(Clock.systemDefaultZone()), "NULL", null); TestUtil.testCall(db, "RETURN apoc.meta.cypher.types({param}) AS value", singletonMap("param",param), row -> { Map<String, Object> r = (Map<String, Object>) row.get("value"); assertEquals("DATE", r.get("DATE")); assertEquals("LOCAL_DATE_TIME", r.get("LOCAL_DATE")); assertEquals("TIME", r.get("TIME")); assertEquals("LOCAL_TIME", r.get("LOCAL_TIME")); assertEquals("DATE_TIME", r.get("DATE_TIME")); assertEquals("NULL", r.get("NULL")); }); }
public static DateTimeValue now( Clock clock, Supplier<ZoneId> defaultZone ) { return now( clock.withZone( defaultZone.get() ) ); }
public static DateTimeValue now( Clock clock, String timezone ) { return now( clock.withZone( parseZoneName( timezone ) ) ); }