Search in sources :

Example 31 with Timestamp

use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationWithTypeInfo04NonUTCOffset.

@Test
public void testDeserializationWithTypeInfo04NonUTCOffset() throws Exception {
    Instant now = Instant.now();
    ZonedDateTime expected = ZonedDateTime.ofInstant(now, Z1);
    IonObjectMapper m = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).build();
    Timestamp timestamp = TimestampUtils.toTimestamp(now, expected.getOffset());
    Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class);
    assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime);
    assertEquals("The value is not correct.", expected, actual);
}
Also used : Temporal(java.time.temporal.Temporal) ZonedDateTime(java.time.ZonedDateTime) Instant(java.time.Instant) Timestamp(com.amazon.ion.Timestamp) IonObjectMapper(com.fasterxml.jackson.dataformat.ion.IonObjectMapper) Test(org.junit.Test)

Example 32 with Timestamp

use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationAsIonTimestamp02NonUTCTimeOffset.

@Test
public void testDeserializationAsIonTimestamp02NonUTCTimeOffset() throws Exception {
    ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z1);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString());
    assertEquals("The value is not correct.", expected, actual);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Timestamp(com.amazon.ion.Timestamp) Test(org.junit.Test)

Example 33 with Timestamp

use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationAsIonTimestamp01.

/*
     **********************************************************************
     * Deserialization from Ion timestamp value
     **********************************************************************
     */
@Test
public void testDeserializationAsIonTimestamp01() throws Exception {
    ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), UTC);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString());
    assertEquals("The value is not correct.", expected, actual);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Timestamp(com.amazon.ion.Timestamp) Test(org.junit.Test)

Example 34 with Timestamp

use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationAsIonTimestamp03.

@Test
public void testDeserializationAsIonTimestamp03() throws Exception {
    ZonedDateTime expected = ZonedDateTime.now(UTC);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    ZonedDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString());
    assertEquals("The value is not correct.", expected, actual);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Timestamp(com.amazon.ion.Timestamp) Test(org.junit.Test)

Example 35 with Timestamp

use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.

the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationAsIonTimestamp04UnknownOffset.

@Test
public void testDeserializationAsIonTimestamp04UnknownOffset() throws Exception {
    OffsetDateTime expected = OffsetDateTime.now(UTC);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), null);
    OffsetDateTime actual = READER_UTC_DEFAULT.readValue(timestamp.toString());
    assertEquals("The value is not correct.", expected, actual);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Timestamp(com.amazon.ion.Timestamp) Test(org.junit.Test)

Aggregations

Timestamp (com.amazon.ion.Timestamp)51 Test (org.junit.Test)38 Instant (java.time.Instant)13 OffsetDateTime (java.time.OffsetDateTime)10 ZonedDateTime (java.time.ZonedDateTime)10 IonReader (com.amazon.ion.IonReader)8 IonObjectMapper (com.fasterxml.jackson.dataformat.ion.IonObjectMapper)8 RepeatInputStream (com.amazon.ion.util.RepeatInputStream)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 InputStream (java.io.InputStream)7 SequenceInputStream (java.io.SequenceInputStream)7 BigInteger (java.math.BigInteger)7 IonTimestamp (com.amazon.ion.IonTimestamp)6 BigDecimal (java.math.BigDecimal)5 Temporal (java.time.temporal.Temporal)5 Decimal (com.amazon.ion.Decimal)2 IonException (com.amazon.ion.IonException)2 IonWriter (com.amazon.ion.IonWriter)2 IonBlob (com.amazon.ion.IonBlob)1