Skip to content

Commit 4e6c266

Browse files
committed
Merge branch '2.4'
2 parents 393dae2 + 75e8ef7 commit 4e6c266

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/java/com/fasterxml/jackson/datatype/joda/JodaSerializationTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.fasterxml.jackson.datatype.joda;
22

33
import java.io.IOException;
4+
import java.text.SimpleDateFormat;
45

56
import com.fasterxml.jackson.annotation.JsonInclude;
67
import org.joda.time.*;
@@ -235,6 +236,23 @@ public void testInstantSer() throws IOException {
235236
.writeValueAsString(instant));
236237
}
237238

239+
// [datatype-joda#60]
240+
public void testInstantConversion() throws Exception
241+
{
242+
final ObjectMapper mapper = jodaMapper();
243+
244+
// Configure Date Formatting
245+
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
246+
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));
247+
248+
// Create an instant and serialize and additonally serialize the instant as DateTime to demonstrate the difference
249+
org.joda.time.Instant now = new DateTime(1431498572205L).toInstant();
250+
251+
String instantString = mapper.writeValueAsString(now);
252+
253+
assertEquals("\"2015-05-13T06:29:32.205Z\"", instantString);
254+
}
255+
238256
public void testMonthDaySer() throws Exception
239257
{
240258
MonthDay monthDay = new MonthDay(7, 23);

0 commit comments

Comments
 (0)