diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java index 99b1558dc..bde36f773 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java @@ -93,9 +93,10 @@ public class DateConverter extends DefaultTypeConverter { DateFormat d2 = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); DateFormat d3 = DateFormat.getDateInstance(DateFormat.LONG, locale); - DateFormat rfc3399 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + DateFormat rfc3339 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + DateFormat rfc3339dateOnly = new SimpleDateFormat("yyyy-MM-dd"); - return new DateFormat[]{dt1, dt2, dt3, rfc3399, d1, d2, d3}; + return new DateFormat[]{dt1, dt2, dt3, rfc3339, d1, d2, d3, rfc3339dateOnly}; } } diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java index 3d7fc493e..d185c6471 100644 --- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java @@ -109,6 +109,13 @@ public class XWorkConverterTest extends XWorkTestCase { assertEquals(date, ts); java.sql.Time time1 = (java.sql.Time) converter.convertValue(context, null, null, null, datetStr, java.sql.Time.class); assertEquals(datet, time1); + + Date dateWithTime = format.parse("01/10/2001 01:02:03"); + Date dateRfc3339 = (Date) converter.convertValue(context, null, null, null, "2001-01-10T01:02:03", Date.class); + assertEquals(dateWithTime, dateRfc3339); + + Date dateRfc3339DateOnly = (Date) converter.convertValue(context, null, null, null, "2001-01-10", Date.class); + assertEquals(date, dateRfc3339DateOnly); } public void testFieldErrorMessageAddedForComplexProperty() {