commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject [lang] LANG-1247: FastDatePrinter generates Date objects wastefully closes #168
Date Tue, 05 Jul 2016 20:44:04 GMT
Repository: commons-lang
Updated Branches:
  refs/heads/master 03384395a -> caaf97ed8


LANG-1247: FastDatePrinter generates Date objects wastefully
closes #168


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

Branch: refs/heads/master
Commit: caaf97ed8804ae3bf6fb17cd98a5814cab834688
Parents: 0338439
Author: Chas Honton <chas@apache.org>
Authored: Tue Jul 5 13:42:48 2016 -0700
Committer: Chas Honton <chas@apache.org>
Committed: Tue Jul 5 13:42:55 2016 -0700

----------------------------------------------------------------------
 src/changes/changes.xml                                      | 1 +
 .../java/org/apache/commons/lang3/time/FastDatePrinter.java  | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/caaf97ed/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8b4e061..8887572 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
   <body>
 
   <release version="3.5" date="tba" description="tba">
+    <action issue="LANG-1247" type="update" dev="chas" due-to="Benoit Wiart">FastDatePrinter
generates extra Date objects</action>
     <action issue="LANG-1018" type="fix" dev="pschumacher" due-to="Nick Manley">Fix
precision loss on NumberUtils.createNumber(String)</action>
     <action issue="LANG-1229" type="update" dev="pschumacher" due-to="Ruslan Cheremin">HashCodeBuilder.append(Object,Object)
is too big to be inlined, which prevents whole builder to be scalarized</action>
     <action issue="LANG-1085" type="add" dev="oheger" due-to="oheger / kinow">Add a
circuit breaker implementation</action>

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/caaf97ed/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
index 4ff2bbc..ece0787 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
@@ -486,7 +486,9 @@ public class FastDatePrinter implements DatePrinter, Serializable {
      */
     @Override
     public StringBuffer format(final long millis, final StringBuffer buf) {
-        return format(new Date(millis), buf);
+        final Calendar c = newCalendar();
+        c.setTimeInMillis(millis);
+        return applyRules(c, buf);
     }
 
     /* (non-Javadoc)
@@ -513,7 +515,9 @@ public class FastDatePrinter implements DatePrinter, Serializable {
      */
     @Override
     public <B extends Appendable> B format(final long millis, final B buf) {
-        return format(new Date(millis), buf);
+        final Calendar c = newCalendar();
+        c.setTimeInMillis(millis);
+        return applyRules(c, buf);
     }
 
     /* (non-Javadoc)


Mime
View raw message