@Override public Value asValue() { return LocalTimeValue.localTime( nanoOfDay ); }
@Test void shouldParseTimeWithHourMinuteAndSecond() { assertEquals( localTime( 14, 5, 17, 0 ), parse( "140517" ) ); assertEquals( localTime( 14, 5, 17, 0 ), parse( "14:5:17" ) ); assertEquals( localTime( 4, 15, 4, 0 ), parse( "4:15:4" ) ); assertEquals( localTime( 9, 7, 19, 0 ), parse( "9:7:19" ) ); assertEquals( localTime( 3, 4, 1, 0 ), parse( "03:04:01" ) ); }
@Test public void shouldHandleLocalTime() { // Given LocalTimeValue dvalue = LocalTimeValue.localTime( 1, 2, 3, 4 ); // When dvalue.writeTo( converter ); // Then Object value = converter.value(); assertThat( value, instanceOf( LocalTime.class ) ); assertThat( value, equalTo( dvalue.asObjectCopy() ) ); }
public static LocalTimeValue localTime( long nanoOfDay ) { return new LocalTimeValue( localTimeRaw( nanoOfDay ) ); }
@Override public void writeLocalTime( LocalTime localTime ) throws RuntimeException { builder.append( LocalTimeValue.localTime( localTime ).prettyPrint() ); builder.append( '|' ); }
public static LocalTimeValue truncate( TemporalUnit unit, TemporalValue input, MapValue fields, Supplier<ZoneId> defaultZone ) { LocalTime localTime = input.getLocalTimePart(); LocalTime truncatedLT = assertValidUnit( () -> localTime.truncatedTo( unit ) ); if ( fields.size() == 0 ) { return localTime( truncatedLT ); } else { return updateFieldMapWithConflictingSubseconds( fields, unit, truncatedLT, ( mapValue, localTime1 ) -> { if ( mapValue.size() == 0 ) { return localTime( localTime1 ); } else { return build( mapValue.updatedWith( "time", localTime( localTime1 ) ), defaultZone ); } } ); } }
@Test public void testLocalTimeTypeSmallNano() { LocalTime time = LocalTimeValue.localTime( 0, 0, 0, 37 ).asObjectCopy(); String key = "dt"; node1.setProperty( key, time ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( time, property ); }
@Override protected LocalTimeValue parse( TextValue value, Supplier<ZoneId> defaultZone ) { return LocalTimeValue.parse( value ); }
@Test void shouldWriteLocalTime() { // given for ( LocalTimeValue value : new LocalTimeValue[] { localTime( 0, 0, 0, 0 ), localTime( 11, 22, 33, 123456789 ), localTime( 2, 3, 4, 5 ), localTime( 23, 59, 59, 999999999 ), } ) { List<LocalTimeValue> values = new ArrayList<>( 1 ); ValueWriter<RuntimeException> writer = new ThrowingValueWriter.AssertOnly() { @Override public void writeLocalTime( LocalTime localTime ) { values.add( localTime( localTime ) ); } }; // when value.writeTo( writer ); // then assertEquals( singletonList( value ), values ); } }
static LocalTime asValueRaw( long long0 ) { return LocalTimeValue.localTimeRaw( long0 ); }
@Override public LocalTime mapLocalTime( LocalTimeValue value ) { return value.asObjectCopy(); }
@Override protected LocalTimeValue build( MapValue map, Supplier<ZoneId> defaultZone ) { return LocalTimeValue.build( map, defaultZone ); }
@Test public void testLocalTimeTypeLargeNano() { LocalTime time = LocalTimeValue.localTime( 0, 0, 13, 37 ).asObjectCopy(); String key = "dt"; node1.setProperty( key, time ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( time, property ); }
public static LocalTimeValue truncate( TemporalUnit unit, TemporalValue input, MapValue fields, Supplier<ZoneId> defaultZone ) { LocalTime localTime = input.getLocalTimePart(); LocalTime truncatedLT = assertValidUnit( () -> localTime.truncatedTo( unit ) ); if ( fields.size() == 0 ) { return localTime( truncatedLT ); } else { return updateFieldMapWithConflictingSubseconds( fields, unit, truncatedLT, ( mapValue, localTime1 ) -> { if ( mapValue.size() == 0 ) { return localTime( localTime1 ); } else { return build( mapValue.updatedWith( "time", localTime( localTime1 ) ), defaultZone ); } } ); } }
public static LocalTimeValue parse( TextValue text ) { return parse( LocalTimeValue.class, PATTERN, LocalTimeValue::parse, text ); }
@Override public void writeLocalTime( LocalTime localTime ) throws RuntimeException { builder.append( LocalTimeValue.localTime( localTime ).prettyPrint() ); builder.append( '|' ); }
public static LocalTimeValue now( Clock clock, Supplier<ZoneId> defaultZone ) { return now( clock.withZone( defaultZone.get() ) ); }
@Test public void shouldRangeSeekInOrderDescendingLocalTime() throws Exception { Object o0 = LocalTimeValue.localTimeRaw( 0 ); Object o1 = LocalTimeValue.localTimeRaw( 1 ); Object o2 = LocalTimeValue.localTimeRaw( 2 ); Object o3 = LocalTimeValue.localTimeRaw( 3 ); Object o4 = LocalTimeValue.localTimeRaw( 4 ); Object o5 = LocalTimeValue.localTimeRaw( 5 ); shouldRangeSeekInOrder( IndexOrder.DESCENDING, o0, o1, o2, o3, o4, o5 ); }