use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantDeserializerTest method testDeserializationFromStringWithNonZeroOffset02.
@Test
public void testDeserializationFromStringWithNonZeroOffset02() 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);
}
use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantDeserializerTest method testDeserializationWithTypeInfo04.
@Test
public void testDeserializationWithTypeInfo04() throws Exception {
Instant expected = Instant.now();
IonObjectMapper m = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Timestamp timestamp = TimestampUtils.toTimestamp(expected, ZoneOffset.UTC);
Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class);
assertTrue("The actual should be an Instant.", actual instanceof Instant);
assertEquals("The value is not correct.", expected, actual);
}
use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantSerializerTest method testSerializationAsString01.
@Test
public void testSerializationAsString01() throws Exception {
IonObjectMapper mapper = newMapperBuilder().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
Instant date = Instant.ofEpochSecond(0L);
Timestamp value = ((IonTimestamp) mapper.writeValueAsIonValue(date)).timestampValue();
assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value);
}
use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantSerializerTest method testSerializationAsString02.
@Test
public void testSerializationAsString02() throws Exception {
IonObjectMapper mapper = newMapperBuilder().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
Instant date = Instant.ofEpochSecond(123456789L, 183917322);
Timestamp value = ((IonTimestamp) mapper.writeValueAsIonValue(date)).timestampValue();
assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date, ZoneOffset.UTC), value);
}
use of com.amazon.ion.Timestamp in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationAsIonTimestamp03.
@Test
public void testDeserializationAsIonTimestamp03() throws Exception {
OffsetDateTime expected = OffsetDateTime.now(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);
}
Aggregations