Author: bayard
Date: Wed Sep  8 06:09:57 2010
New Revision: 993620

URL: http://svn.apache.org/viewvc?rev=993620&view=rev
Log:
Applying my fix to LANG-645, and Mikael's test case; fixing the FastDateFormat 
to properly include the locale when formatting a Date

Modified:
    
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
    
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java

Modified: 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
URL: 
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java?rev=993620&r1=993619&r2=993620&view=diff
==============================================================================
--- 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
 (original)
+++ 
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
 Wed Sep  8 06:09:57 2010
@@ -817,7 +817,7 @@ public class FastDateFormat extends Form
      * @return the formatted string
      */
     public String format(Date date) {
-        Calendar c = new GregorianCalendar(mTimeZone);
+        Calendar c = new GregorianCalendar(mTimeZone, mLocale);
         c.setTime(date);
         return applyRules(c, new StringBuffer(mMaxLengthEstimate)).toString();
     }

Modified: 
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java?rev=993620&r1=993619&r2=993620&view=diff
==============================================================================
--- 
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
 (original)
+++ 
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java
 Wed Sep  8 06:09:57 2010
@@ -322,4 +322,16 @@ public class FastDateFormatTest extends 
         FastDateFormat format = 
FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", 
TimeZone.getTimeZone("GMT"));
         assertEquals("dateTime", dateTime, format.format(cal));
     }
+
+    public void testLang645() {
+        Locale locale = new Locale("sv", "SE");
+
+        Calendar cal = Calendar.getInstance();
+        cal.set(2010, 0, 1, 12, 0, 0);
+        Date d = cal.getTime();
+
+        FastDateFormat fdf = FastDateFormat.getInstance("EEEE', week 'ww", 
locale);
+
+        assertEquals("fredag, week 53", fdf.format(d));
+    }
 }


Reply via email to