File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/test/java/com/fasterxml/jackson/databind/ser Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,15 @@ static class DateInCETBean {
3737 public Date date ;
3838 public DateInCETBean (long l ) { date = new java .util .Date (l ); }
3939 }
40+
41+ static class CalendarAsStringBean {
42+ @ JsonFormat (shape =JsonFormat .Shape .STRING , pattern ="yyyy-MM-dd" )
43+ public Calendar value ;
44+ public CalendarAsStringBean (long l ) {
45+ value = new GregorianCalendar ();
46+ value .setTimeInMillis (l );
47+ }
48+ }
4049
4150 /*
4251 /**********************************************************
@@ -146,6 +155,10 @@ public void testDateWithJsonFormat() throws Exception
146155 // and with different DateFormat; CET is one hour ahead of GMT
147156 json = mapper .writeValueAsString (new DateInCETBean (0L ));
148157 assertEquals ("{\" date\" :\" 1970-01-01,01:00\" }" , json );
158+
159+ // and for [Issue#423] as well:
160+ json = mapper .writer ().with (getUTCTimeZone ()).writeValueAsString (new CalendarAsStringBean (0L ));
161+ assertEquals ("{\" date\" :\" 1970-01-01\" }" , json );
149162 }
150163
151164 /**
You can’t perform that action at this time.
0 commit comments