Title: [2263] branches/v-1.4.x: Fix: DateConverter ignores provided locale.

Diff

Modified: branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/basic/DateConverter.java (2262 => 2263)


--- branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/basic/DateConverter.java	2014-02-10 23:10:50 UTC (rev 2262)
+++ branches/v-1.4.x/xstream/src/java/com/thoughtworks/xstream/converters/basic/DateConverter.java	2014-02-10 23:57:21 UTC (rev 2263)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2003, 2004 Joe Walnes.
- * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012, 2013 XStream Committers.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -189,7 +189,7 @@
             : new ThreadSafeSimpleDateFormat[0];
         for (int i = 0; i < this.acceptableFormats.length; i++ ) {
             this.acceptableFormats[i] = new ThreadSafeSimpleDateFormat(
-                acceptableFormats[i], timeZone, 1, 20, lenient);
+                acceptableFormats[i], timeZone, locale, 1, 20, lenient);
         }
     }
 

Modified: branches/v-1.4.x/xstream/src/test/com/thoughtworks/xstream/converters/basic/DateConverterTest.java (2262 => 2263)


--- branches/v-1.4.x/xstream/src/test/com/thoughtworks/xstream/converters/basic/DateConverterTest.java	2014-02-10 23:10:50 UTC (rev 2262)
+++ branches/v-1.4.x/xstream/src/test/com/thoughtworks/xstream/converters/basic/DateConverterTest.java	2014-02-10 23:57:21 UTC (rev 2263)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2004, 2005 Joe Walnes.
- * Copyright (C) 2006, 2007, 2008, 2009, 2012 XStream Committers.
+ * Copyright (C) 2006, 2007, 2008, 2009, 2012, 2014 XStream Committers.
  * All rights reserved.
  *
  * The software in this package is published under the terms of the BSD
@@ -215,4 +215,28 @@
         cal.add(Calendar.MILLISECOND, 1);
         assertEquals(cal.getTime(), converter.fromString("0001-01-01 AD 00:00:00.000 UTC"));
     }
+    
+    public void testDatesWithEnglishLocaleOfDefault() {
+        converter = new DateConverter(null, "EEEE, dd MMMM yyyy z", 
+            null, Locale.ENGLISH, TimeZone.getTimeZone("UTC"), false);
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+        cal.clear();
+        cal.set(2000, Calendar.JANUARY, 1);
+        Date date = cal.getTime();
+        assertEquals("Saturday, 01 January 2000 UTC", converter.toString(date));
+        assertEquals(date, converter.fromString("Saturday, 01 January 2000 UTC"));
+    }
+    
+    public void testDatesWithGermanLocale() {
+        converter = new DateConverter(null, "EEEE, dd MMMM yyyy z", 
+            null, Locale.GERMAN, TimeZone.getTimeZone("UTC"), false);
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+        cal.clear();
+        cal.set(2000, Calendar.JANUARY, 1);
+        Date date = cal.getTime();
+        assertEquals("Samstag, 01 Januar 2000 UTC", converter.toString(date));
+        assertEquals(date, converter.fromString("Samstag, 01 Januar 2000 UTC"));
+    }
 }

Modified: branches/v-1.4.x/xstream-distribution/src/content/changes.html (2262 => 2263)


--- branches/v-1.4.x/xstream-distribution/src/content/changes.html	2014-02-10 23:10:50 UTC (rev 2262)
+++ branches/v-1.4.x/xstream-distribution/src/content/changes.html	2014-02-10 23:57:21 UTC (rev 2263)
@@ -32,6 +32,12 @@
 
     <p>Not yet released.</p>
 
+    <h2>Minor changes</h2>
+    
+    <ul>
+    	<li>Fix: DateConverter ignores provided locale.</li>
+    </ul>
+
     <h2>API changes</h2>
     
     <ul>

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to