@@ -117,8 +117,8 @@ public void testDateISO8601() throws IOException
117
117
ObjectMapper mapper = new ObjectMapper ();
118
118
mapper .configure (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS , false );
119
119
120
- serialize ( mapper , judate (1970 , 1 , 1 , 02 , 00 , 00 , 0 , "GMT+2" ), "1970-01-01T00:00:00.000+0000 " );
121
- serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "UTC" ), "1970-01-01T00:00:00.000+0000 " );
120
+ serialize ( mapper , judate (1970 , 1 , 1 , 02 , 00 , 00 , 0 , "GMT+2" ), "1970-01-01T00:00:00.000+00:00 " );
121
+ serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "UTC" ), "1970-01-01T00:00:00.000+00:00 " );
122
122
}
123
123
124
124
/**
@@ -130,8 +130,8 @@ public void testDateISO8601_customTZ() throws IOException
130
130
mapper .configure (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS , false );
131
131
mapper .setTimeZone (TimeZone .getTimeZone ("GMT+2" ));
132
132
133
- serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "GMT+2" ), "1970-01-01T00:00:00.000+0200 " );
134
- serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "UTC" ), "1970-01-01T02:00:00.000+0200 " );
133
+ serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "GMT+2" ), "1970-01-01T00:00:00.000+02:00 " );
134
+ serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "UTC" ), "1970-01-01T02:00:00.000+02:00 " );
135
135
}
136
136
137
137
/**
@@ -142,16 +142,16 @@ public void testDateISO8601_customTZ() throws IOException
142
142
public void testDateISO8601_colonInTZ () throws IOException
143
143
{
144
144
StdDateFormat dateFormat = new StdDateFormat ();
145
- assertFalse (dateFormat .isColonIncludedInTimeZone ());
146
- dateFormat = dateFormat .withColonInTimeZone (true );
147
145
assertTrue (dateFormat .isColonIncludedInTimeZone ());
146
+ dateFormat = dateFormat .withColonInTimeZone (false );
147
+ assertFalse (dateFormat .isColonIncludedInTimeZone ());
148
148
149
149
ObjectMapper mapper = new ObjectMapper ();
150
150
mapper .configure (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS , false );
151
151
mapper .setDateFormat (dateFormat );
152
152
153
- serialize ( mapper , judate (1970 , 1 , 1 , 02 , 00 , 00 , 0 , "GMT+2" ), "1970-01-01T00:00:00.000+00:00 " );
154
- serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "UTC" ), "1970-01-01T00:00:00.000+00:00 " );
153
+ serialize ( mapper , judate (1970 , 1 , 1 , 02 , 00 , 00 , 0 , "GMT+2" ), "1970-01-01T00:00:00.000+0000 " );
154
+ serialize ( mapper , judate (1970 , 1 , 1 , 00 , 00 , 00 , 0 , "UTC" ), "1970-01-01T00:00:00.000+0000 " );
155
155
}
156
156
157
157
public void testDateOther () throws IOException
@@ -202,7 +202,7 @@ public void testDatesAsMapKeys() throws IOException
202
202
assertFalse (mapper .isEnabled (SerializationFeature .WRITE_DATE_KEYS_AS_TIMESTAMPS ));
203
203
map .put (new Date (0L ), Integer .valueOf (1 ));
204
204
// by default will serialize as ISO-8601 values...
205
- assertEquals ("{\" 1970-01-01T00:00:00.000+0000 \" :1}" , mapper .writeValueAsString (map ));
205
+ assertEquals ("{\" 1970-01-01T00:00:00.000+00:00 \" :1}" , mapper .writeValueAsString (map ));
206
206
207
207
// but can change to use timestamps too
208
208
mapper .configure (SerializationFeature .WRITE_DATE_KEYS_AS_TIMESTAMPS , true );
@@ -234,7 +234,7 @@ public void testDateWithJsonFormat() throws Exception
234
234
235
235
// and with default (ISO8601) format (databind#1109)
236
236
json = mapper .writeValueAsString (new DateAsDefaultStringBean (0L ));
237
- assertEquals ("{\" date\" :\" 1970-01-01T00:00:00.000+0000 \" }" , json );
237
+ assertEquals ("{\" date\" :\" 1970-01-01T00:00:00.000+00:00 \" }" , json );
238
238
}
239
239
240
240
/**
@@ -275,15 +275,15 @@ public void testDateDefaultShape() throws Exception
275
275
assertEquals (aposToQuotes ("{'date':0}" ), json );
276
276
mapper .disable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
277
277
json = mapper .writeValueAsString (new DateAsDefaultBean (0L ));
278
- assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+0000 '}" ), json );
278
+ assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+00:00 '}" ), json );
279
279
280
280
// Empty @JsonFormat => default to user config
281
281
mapper .enable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
282
282
json = mapper .writeValueAsString (new DateAsDefaultBeanWithEmptyJsonFormat (0L ));
283
283
assertEquals (aposToQuotes ("{'date':0}" ), json );
284
284
mapper .disable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
285
285
json = mapper .writeValueAsString (new DateAsDefaultBeanWithEmptyJsonFormat (0L ));
286
- assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+0000 '}" ), json );
286
+ assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+00:00 '}" ), json );
287
287
288
288
// @JsonFormat with Shape.ANY and pattern => STRING shape, regardless of user config
289
289
mapper .enable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
@@ -296,18 +296,18 @@ public void testDateDefaultShape() throws Exception
296
296
// @JsonFormat with Shape.ANY and locale => STRING shape, regardless of user config
297
297
mapper .enable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
298
298
json = mapper .writeValueAsString (new DateAsDefaultBeanWithLocale (0L ));
299
- assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+0000 '}" ), json );
299
+ assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+00:00 '}" ), json );
300
300
mapper .disable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
301
301
json = mapper .writeValueAsString (new DateAsDefaultBeanWithLocale (0L ));
302
- assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+0000 '}" ), json );
302
+ assertEquals (aposToQuotes ("{'date':'1970-01-01T00:00:00.000+00:00 '}" ), json );
303
303
304
304
// @JsonFormat with Shape.ANY and timezone => STRING shape, regardless of user config
305
305
mapper .enable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
306
306
json = mapper .writeValueAsString (new DateAsDefaultBeanWithTimezone (0L ));
307
- assertEquals (aposToQuotes ("{'date':'1970-01-01T01:00:00.000+0100 '}" ), json );
307
+ assertEquals (aposToQuotes ("{'date':'1970-01-01T01:00:00.000+01:00 '}" ), json );
308
308
mapper .disable (SerializationFeature .WRITE_DATES_AS_TIMESTAMPS );
309
309
json = mapper .writeValueAsString (new DateAsDefaultBeanWithTimezone (0L ));
310
- assertEquals (aposToQuotes ("{'date':'1970-01-01T01:00:00.000+0100 '}" ), json );
310
+ assertEquals (aposToQuotes ("{'date':'1970-01-01T01:00:00.000+01:00 '}" ), json );
311
311
}
312
312
313
313
// [databind#1648]: contextual default format should be used
0 commit comments