Search in sources :

Example 36 with Timestamp

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

the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationAsIonTimestamp01.

/*
     **********************************************************************
     * Deserialization from Ion timestamp value
     **********************************************************************
     */
@Test
public void testDeserializationAsIonTimestamp01() throws Exception {
    OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), UTC);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    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)

Example 37 with Timestamp

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

the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationAsIonTimestamp03NonUTCTimeOffset.

@Test
public void testDeserializationAsIonTimestamp03NonUTCTimeOffset() throws Exception {
    OffsetDateTime expected = OffsetDateTime.now(Z1);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    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)

Example 38 with Timestamp

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

the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationAsIonTimestamp02NonUTCTimeOffset.

@Test
public void testDeserializationAsIonTimestamp02NonUTCTimeOffset() throws Exception {
    OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z1);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    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)

Example 39 with Timestamp

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

the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationAsIonTimestamp01NonUTCTimeOffset.

@Test
public void testDeserializationAsIonTimestamp01NonUTCTimeOffset() throws Exception {
    OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    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)

Example 40 with Timestamp

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

the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationAsIonTimestamp02.

@Test
public void testDeserializationAsIonTimestamp02() throws Exception {
    OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), UTC);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), expected.getOffset());
    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