Search in sources :

Example 21 with Timestamp

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

the class IonTimestampInstantDeserializerTest method testDeserializationAsIonTimestamp01.

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

Example 22 with Timestamp

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

the class IonTimestampInstantDeserializerTest method testDeserializationFromStringWithNonZeroOffset01.

@Test
public void testDeserializationFromStringWithNonZeroOffset01() throws Exception {
    Instant expected = Instant.now();
    Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.ofHours(8));
    Instant result = READER.readValue(timestamp.toString());
    assertEquals("The value is not correct.", expected, result);
}
Also used : Instant(java.time.Instant) Timestamp(com.amazon.ion.Timestamp) Test(org.junit.Test)

Example 23 with Timestamp

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

the class IonTimestampInstantDeserializerTest method testDeserializationAsIonTimestamp02.

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

Example 24 with Timestamp

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

the class IonTimestampInstantDeserializerTest method testDeserializationAsIonTimestamp03.

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

Example 25 with Timestamp

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

the class IonTimestampInstantSerializerTest method testSerializationAsString03.

@Test
public void testSerializationAsString03() throws Exception {
    IonObjectMapper mapper = newMapperBuilder().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
    Instant date = Instant.now();
    Timestamp value = ((IonTimestamp) mapper.writeValueAsIonValue(date)).timestampValue();
    assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value);
}
Also used : IonTimestamp(com.amazon.ion.IonTimestamp) Instant(java.time.Instant) Timestamp(com.amazon.ion.Timestamp) IonTimestamp(com.amazon.ion.IonTimestamp) IonObjectMapper(com.fasterxml.jackson.dataformat.ion.IonObjectMapper) 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