File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/test/java/com/fasterxml/jackson/datatype/joda Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .datatype .joda ;
2
2
3
3
import java .io .IOException ;
4
+ import java .text .SimpleDateFormat ;
4
5
5
6
import com .fasterxml .jackson .annotation .JsonInclude ;
6
7
import org .joda .time .*;
@@ -235,6 +236,23 @@ public void testInstantSer() throws IOException {
235
236
.writeValueAsString (instant ));
236
237
}
237
238
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
+
238
256
public void testMonthDaySer () throws Exception
239
257
{
240
258
MonthDay monthDay = new MonthDay (7 , 23 );
You can’t perform that action at this time.
0 commit comments