Skip to content

Commit e6e15a5

Browse files
committed
Add a test for #423
1 parent c3590d7 commit e6e15a5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/java/com/fasterxml/jackson/databind/ser/TestDateSerialization.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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
/**

0 commit comments

Comments
 (0)