struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: WW-4551 Adds support for conversion of RFC3339 dates with date part only
Date Sat, 10 Oct 2015 08:01:48 GMT
Repository: struts
Updated Branches:
  refs/heads/support-2-3 4f817dc7a -> f5d455da1


WW-4551 Adds support for conversion of RFC3339 dates with date part only


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f5d455da
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f5d455da
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f5d455da

Branch: refs/heads/support-2-3
Commit: f5d455da121840b39ce2a960011363d5ae2af12a
Parents: 4f817dc
Author: Lukasz Lenart <lukasz.lenart@gmail.com>
Authored: Sat Oct 10 10:01:33 2015 +0200
Committer: Lukasz Lenart <lukasz.lenart@gmail.com>
Committed: Sat Oct 10 10:01:33 2015 +0200

----------------------------------------------------------------------
 .../opensymphony/xwork2/conversion/impl/DateConverter.java  | 5 +++--
 .../xwork2/conversion/impl/XWorkConverterTest.java          | 9 ++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/f5d455da/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java
index 99b1558..bde36f7 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java
+++ b/xwork-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};
     }
 
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/f5d455da/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
index bc0d932..a521e74 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java
@@ -122,6 +122,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() {
@@ -727,4 +734,4 @@ class ListAction {
         this.ints = ints;
     }
 
-}
\ No newline at end of file
+}


Mime
View raw message