use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationAsTimestamp01Nanoseconds.
@Test
public void testSerializationAsTimestamp01Nanoseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "0.", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationWithTypeInfo02.
@Test
public void testSerializationWithTypeInfo02() throws Exception {
OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2);
IonObjectMapper mapper = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "'" + OffsetDateTime.class.getName() + "'::123456789183", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationAsTimestamp01Milliseconds.
@Test
public void testSerializationAsTimestamp01Milliseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "0", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationAsString01.
@Test
public void testSerializationAsString01() throws Exception {
OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1);
IonObjectMapper mapper = newMapperBuilder().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampZonedDateTimeDeserializerTest method testDeserializationWithTypeInfo03NonUTCDefault.
@Test
public void testDeserializationWithTypeInfo03NonUTCDefault() throws Exception {
ZonedDateTime expected = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 422000000), Z1);
IonObjectMapper m = newMapperBuilder().defaultTimeZone(TimeZone.getTimeZone(Z1)).disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Temporal actual = m.readValue("[\"" + ZonedDateTime.class.getName() + "\", 123456789422]", Temporal.class);
assertTrue("The value should be an ZonedDateTime.", actual instanceof ZonedDateTime);
assertEquals("The value is not correct.", expected, actual);
}
Aggregations