commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1406026 - in /commons/proper/lang/trunk/src: changes/changes.xml main/java/org/apache/commons/lang3/time/FastDateFormat.java main/java/org/apache/commons/lang3/time/FastDatePrinter.java
Date Tue, 06 Nov 2012 01:58:29 GMT
Author: ggregory
Date: Tue Nov  6 01:58:29 2012
New Revision: 1406026

URL: http://svn.apache.org/viewvc?rev=1406026&view=rev
Log:
[LANG-849] FastDateFormat generates Date objects wastefully.

Modified:
    commons/proper/lang/trunk/src/changes/changes.xml
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java

Modified: commons/proper/lang/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/changes/changes.xml?rev=1406026&r1=1406025&r2=1406026&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/changes/changes.xml (original)
+++ commons/proper/lang/trunk/src/changes/changes.xml Tue Nov  6 01:58:29 2012
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.2" date="TBA" description="Next release">
+    <action issue="LANG-849" type="fix">FastDateFormat generates Date objects wastefully</action>
     <action issue="LANG-845" type="fix">Spelling fixes</action>
     <action issue="LANG-844" type="fix">Fix examples contained in javadoc of StringUtils.center
methods</action>
     <action issue="LANG-841" type="add">Add StringUtils API to call String.replaceAll
in DOTALL a.k.a. single-line mode</action>    

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=1406026&r1=1406025&r2=1406026&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
Tue Nov  6 01:58:29 2012
@@ -395,7 +395,7 @@ public class FastDateFormat extends Form
      */
     @Override
     public String format(long millis) {
-        return format(new Date(millis));
+        return printer.format(millis);
     }
 
     /**

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java?rev=1406026&r1=1406025&r2=1406026&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
Tue Nov  6 01:58:29 2012
@@ -394,7 +394,9 @@ public class FastDatePrinter implements 
      */
     @Override
     public String format(long millis) {
-        return format(new Date(millis));
+        Calendar c = new GregorianCalendar(mTimeZone, mLocale);  // hard code GregorianCalendar
+        c.setTimeInMillis(millis);
+        return applyRules(c, new StringBuffer(mMaxLengthEstimate)).toString();
     }
 
     /* (non-Javadoc)



Mime
View raw message