use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampZonedDateTimeSerializerTest 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();
ZonedDateTime date = ZonedDateTime.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 IonTimestampZonedDateTimeSerializerTest method testSerializationWithTypeInfo02.
@Test
public void testSerializationWithTypeInfo02() throws Exception {
ZonedDateTime date = ZonedDateTime.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.", "'" + ZonedDateTime.class.getName() + "'::123456789183", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantSerializerTest method testSerializationAsTimestamp02Nanoseconds.
@Test
public void testSerializationAsTimestamp02Nanoseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
Instant date = Instant.ofEpochSecond(123456789L, 183917322);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "123456789.183917322", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantSerializerTest method testSerializationAsTimestamp03Milliseconds.
@Test
public void testSerializationAsTimestamp03Milliseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
Instant date = Instant.now();
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", Long.toString(date.toEpochMilli()), value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantSerializerTest method testSerializationAsTimestamp02Milliseconds.
@Test
public void testSerializationAsTimestamp02Milliseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
Instant date = Instant.ofEpochSecond(123456789L, 183917322);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "123456789183", value);
}
Aggregations