commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r1056869 - in /commons/proper/lang/branches/LANG_2_X/src: main/java/org/apache/commons/lang/time/FastDateFormat.java test/java/org/apache/commons/lang/time/FastDateFormatTest.java
Date Sun, 09 Jan 2011 02:41:35 GMT
Author: niallp
Date: Sun Jan  9 02:41:34 2011
New Revision: 1056869

URL: http://svn.apache.org/viewvc?rev=1056869&view=rev
Log:
Port LANG-645 to LANG 2.x Branch - fix the FastDateFormat to properly include the locale when
formatting a Date

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

Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/FastDateFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/FastDateFormat.java?rev=1056869&r1=1056868&r2=1056869&view=diff
==============================================================================
--- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/FastDateFormat.java
(original)
+++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/time/FastDateFormat.java
Sun Jan  9 02:41:34 2011
@@ -815,7 +815,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/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/FastDateFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/FastDateFormatTest.java?rev=1056869&r1=1056868&r2=1056869&view=diff
==============================================================================
--- commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/FastDateFormatTest.java
(original)
+++ commons/proper/lang/branches/LANG_2_X/src/test/java/org/apache/commons/lang/time/FastDateFormatTest.java
Sun Jan  9 02:41:34 2011
@@ -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));
+    }
 }



Mime
View raw message