|
|
|
@ -58,6 +58,7 @@ import com.fasterxml.jackson.dataformat.xml.XmlMapper;
@@ -58,6 +58,7 @@ import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
|
|
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat; |
|
|
|
|
import com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer; |
|
|
|
|
import org.joda.time.DateTime; |
|
|
|
|
import org.joda.time.DateTimeZone; |
|
|
|
|
import org.joda.time.format.DateTimeFormat; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
@ -223,8 +224,9 @@ public class Jackson2ObjectMapperBuilderTests {
@@ -223,8 +224,9 @@ public class Jackson2ObjectMapperBuilderTests {
|
|
|
|
|
@Test |
|
|
|
|
public void defaultModules() throws JsonProcessingException, UnsupportedEncodingException { |
|
|
|
|
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build(); |
|
|
|
|
DateTime dateTime = DateTime.parse("2011-12-03T10:15:30"); |
|
|
|
|
assertEquals("1322903730000", new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")); |
|
|
|
|
Long timestamp = 1322903730000L; |
|
|
|
|
DateTime dateTime = new DateTime(timestamp, DateTimeZone.UTC); |
|
|
|
|
assertEquals(timestamp.toString(), new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-12634
|
|
|
|
@ -232,7 +234,7 @@ public class Jackson2ObjectMapperBuilderTests {
@@ -232,7 +234,7 @@ public class Jackson2ObjectMapperBuilderTests {
|
|
|
|
|
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json() |
|
|
|
|
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) |
|
|
|
|
.modulesToInstall(CustomModule.class).build(); |
|
|
|
|
DateTime dateTime = DateTime.parse("2011-12-03T10:15:30"); |
|
|
|
|
DateTime dateTime = new DateTime(1322903730000L, DateTimeZone.UTC); |
|
|
|
|
assertEquals("\"2011-12-03\"", new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -241,7 +243,7 @@ public class Jackson2ObjectMapperBuilderTests {
@@ -241,7 +243,7 @@ public class Jackson2ObjectMapperBuilderTests {
|
|
|
|
|
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json() |
|
|
|
|
.serializerByType(DateTime.class, new DateTimeSerializer(new JacksonJodaDateFormat(DateTimeFormat.forPattern("YYYY-MM-dd").withZoneUTC()))) |
|
|
|
|
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build(); |
|
|
|
|
DateTime dateTime = DateTime.parse("2011-12-03T10:15:30"); |
|
|
|
|
DateTime dateTime = new DateTime(1322903730000L, DateTimeZone.UTC); |
|
|
|
|
assertEquals("\"2011-12-03\"", new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|