Search in sources :

Example 1 with DateTimeValue

use of org.neo4j.values.storable.DateTimeValue in project neo4j by neo4j.

the class CompositeIndexAccessorCompatibility method testIndexSeekRangeWithExistsByTemporal.

@Test
public void testIndexSeekRangeWithExistsByTemporal() throws Exception {
    DateTimeValue d1 = datetime(9999, 100, ZoneId.of("+18:00"));
    DateTimeValue d2 = datetime(10000, 100, ZoneId.of("UTC"));
    DateTimeValue d3 = datetime(10000, 100, ZoneId.of("+01:00"));
    DateTimeValue d4 = datetime(10000, 100, ZoneId.of("Europe/Stockholm"));
    DateTimeValue d5 = datetime(10000, 100, ZoneId.of("+03:00"));
    testIndexSeekRangeWithExists(d1, d2, d3, d4, d5);
}
Also used : LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) Test(org.junit.Test)

Example 2 with DateTimeValue

use of org.neo4j.values.storable.DateTimeValue in project neo4j by neo4j.

the class LiteralJavaccParserTest method shouldInterpretDateTime.

@Test
void shouldInterpretDateTime() throws ParseException {
    DateTimeValue date = DateTimeValue.datetime(2020, 12, 10, 6, 41, 23, 0, DEFAULT_ZONE_ID);
    DateTimeValue dateTimeZone = DateTimeValue.datetime(2020, 12, 10, 6, 41, 23, 0, ZoneId.of("America/Los_Angeles"));
    assertEquals(date, parseLiteral("datetime('2020-12-10T6:41:23.0')"));
    assertEquals(date, parseLiteral("datetime({year:2020, month:12, day:10, hour: 6, minute: 41, second: 23})"));
    assertEquals(dateTimeZone, parseLiteral("datetime({year:2020, month:12, day:10, hour: 6, minute: 41, second: 23, timezone: 'America/Los Angeles'})"));
    // should not throw
    assertNotNull(parseLiteral("datetime()"));
    assertThrows(IllegalArgumentException.class, () -> parseLiteral("datetime(2020, 12, 10, 6, 41, 23, 0)"));
    assertNull(parseLiteral("datetime(null)"));
}
Also used : LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) Test(org.junit.jupiter.api.Test)

Example 3 with DateTimeValue

use of org.neo4j.values.storable.DateTimeValue in project neo4j by neo4j.

the class TestPropertyTypes method testDateTimeTypeWithZoneId.

@Test
void testDateTimeTypeWithZoneId() {
    DateTimeValue dateTime = DateTimeValue.datetime(1991, 1, 1, 0, 0, 13, 37, ZoneId.of("Europe/Stockholm"));
    String key = "dt";
    try (Transaction transaction = getGraphDb().beginTx()) {
        transaction.getNodeById(node1.getId()).setProperty(key, dateTime);
        transaction.commit();
    }
    try (Transaction transaction = getGraphDb().beginTx()) {
        Object property = transaction.getNodeById(node1.getId()).getProperty(key);
        assertEquals(dateTime.asObjectCopy(), property);
        transaction.commit();
    }
}
Also used : LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) Transaction(org.neo4j.graphdb.Transaction) Test(org.junit.jupiter.api.Test)

Example 4 with DateTimeValue

use of org.neo4j.values.storable.DateTimeValue in project neo4j by neo4j.

the class TestPropertyTypes method testDateTimeTypeWithZoneOffset.

@Test
void testDateTimeTypeWithZoneOffset() {
    DateTimeValue dateTime = DateTimeValue.datetime(1991, 1, 1, 0, 0, 13, 37, "+01:00");
    String key = "dt";
    try (Transaction transaction = getGraphDb().beginTx()) {
        transaction.getNodeById(node1.getId()).setProperty(key, dateTime);
        transaction.commit();
    }
    try (Transaction transaction = getGraphDb().beginTx()) {
        Object property = transaction.getNodeById(node1.getId()).getProperty(key);
        assertEquals(dateTime.asObjectCopy(), property);
        transaction.commit();
    }
}
Also used : LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) Transaction(org.neo4j.graphdb.Transaction) Test(org.junit.jupiter.api.Test)

Example 5 with DateTimeValue

use of org.neo4j.values.storable.DateTimeValue in project neo4j by neo4j.

the class PrettyPrinterTest method shouldHandleDateTimeWithTimeZoneId.

@Test
void shouldHandleDateTimeWithTimeZoneId() {
    DateTimeValue datetime = datetime(2045, 2, 7, 12, 0, 40, 999888999, "Europe/London");
    PrettyPrinter printer = new PrettyPrinter();
    datetime.writeTo(printer);
    assertEquals("{datetime: \"2045-02-07T12:00:40.999888999Z[Europe/London]\"}", printer.value());
}
Also used : LocalDateTimeValue(org.neo4j.values.storable.LocalDateTimeValue) DateTimeValue(org.neo4j.values.storable.DateTimeValue) Test(org.junit.jupiter.api.Test)

Aggregations

DateTimeValue (org.neo4j.values.storable.DateTimeValue)8 LocalDateTimeValue (org.neo4j.values.storable.LocalDateTimeValue)8 Test (org.junit.jupiter.api.Test)6 Test (org.junit.Test)2 Transaction (org.neo4j.graphdb.Transaction)2 Duration (java.time.Duration)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 OffsetTime (java.time.OffsetTime)1 Period (java.time.Period)1 ZonedDateTime (java.time.ZonedDateTime)1 TemporalAmount (java.time.temporal.TemporalAmount)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 Function (java.util.function.Function)1 Stream (java.util.stream.Stream)1 EMPTY_BOOLEAN_ARRAY (org.apache.commons.lang3.ArrayUtils.EMPTY_BOOLEAN_ARRAY)1