Search in sources :

Example 26 with Timestamp

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

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationAsIonTimestamp04UnknownOffset.

@Test
public void testDeserializationAsIonTimestamp04UnknownOffset() throws Exception {
    ZonedDateTime expected = ZonedDateTime.now(UTC);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), null);
    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 27 with Timestamp

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

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationAsIonTimestamp03NonUTCTimeOffset.

@Test
public void testDeserializationAsIonTimestamp03NonUTCTimeOffset() throws Exception {
    ZonedDateTime expected = ZonedDateTime.now(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 28 with Timestamp

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

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationWithTypeInfo04.

@Test
public void testDeserializationWithTypeInfo04() throws Exception {
    Instant now = Instant.now();
    ZonedDateTime expected = ZonedDateTime.ofInstant(now, UTC);
    IonObjectMapper m = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).build();
    Timestamp timestamp = TimestampUtils.toTimestamp(now, ZoneOffset.UTC);
    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 29 with Timestamp

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

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationAsIonTimestamp04UnknownOffsetNonUTCDefault.

@Test
public void testDeserializationAsIonTimestamp04UnknownOffsetNonUTCDefault() throws Exception {
    ZonedDateTime expected = ZonedDateTime.now(Z1);
    Timestamp timestamp = TimestampUtils.toTimestamp(expected.toInstant(), null);
    ZonedDateTime actual = READER_Z1_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 30 with Timestamp

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

the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationAsIonTimestamp01NonUTCTimeOffset.

@Test
public void testDeserializationAsIonTimestamp01NonUTCTimeOffset() throws Exception {
    ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), 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)

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