NO NO NO. Please revert this.

The reason this is wrong should be obvious:

+++ 
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
 Sun Sep  4 17:08:54 2011
...
UtilDateTime.DEFAULT_DATE_TIME_FORMAT.setTimeZone(timeZone);


-Adrian


On 9/4/2011 6:08 PM, [email protected] wrote:
Author: jleroux
Date: Sun Sep  4 17:08:54 2011
New Revision: 1165076

URL: http://svn.apache.org/viewvc?rev=1165076&view=rev
Log:
Closes https://issues.apache.org/jira/browse/OFBIZ-4201

"DateFormat.getDateTimeInstance() is very expensive, we can cache it to improve 
performance"

jlr: It's not really cache but a static class constant

Modified:
     
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
     ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java
     ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/FormatTag.java

Modified: 
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java?rev=1165076&r1=1165075&r2=1165076&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
 (original)
+++ 
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
 Sun Sep  4 17:08:54 2011
@@ -554,9 +554,8 @@ public class DateTimeConverters implemen
                  return new java.sql.Timestamp(df.parse(str).getTime());
              } catch (ParseException e) {
                  // before throwing an exception, try a generic format first
-                df = DateFormat.getDateTimeInstance();
                  if (timeZone != null) {
-                    df.setTimeZone(timeZone);
+                    
UtilDateTime.DEFAULT_DATE_TIME_FORMAT.setTimeZone(timeZone);
                  }
                  try {
                      return new java.sql.Timestamp(df.parse(str).getTime());

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java?rev=1165076&r1=1165075&r2=1165076&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java 
(original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilDateTime.java Sun 
Sep  4 17:08:54 2011
@@ -69,7 +69,11 @@ public class UtilDateTime {
      /**
       * JDBC escape format for java.sql.Time conversions.
       */
-    public static final String TIME_FORMAT = "HH:mm:ss";
+
+    public static final String TIME_FORMAT = "HH:mm:ss";
+    public static final DateFormat DEFAULT_DATE_TIME_FORMAT = 
DateFormat.getDateTimeInstance();
+    public static final DateFormat DEFAULT_DATE_FORMAT = 
DateFormat.getDateInstance();
+

      public static double getInterval(Date from, Date thru) {
          return thru != null ? thru.getTime() - from.getTime() : 0;
@@ -699,8 +703,7 @@ public class UtilDateTime {
      }

      public static String toGmtTimestampString(Timestamp timestamp) {
-        DateFormat df = DateFormat.getDateTimeInstance();
-        df.setTimeZone(TimeZone.getTimeZone("GMT"));
+        DEFAULT_DATE_TIME_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
          return df.format(timestamp);
      }


Modified: 
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/FormatTag.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/FormatTag.java?rev=1165076&r1=1165075&r2=1165076&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/FormatTag.java 
(original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/FormatTag.java Sun 
Sep  4 17:08:54 2011
@@ -71,7 +71,7 @@ public class FormatTag extends BodyTagSu
          if (type.charAt(0) == 'N' || type.charAt(0) == 'n')
              nf = NumberFormat.getNumberInstance();
          if (type.charAt(0) == 'D' || type.charAt(0) == 'd')
-            df = DateFormat.getDateInstance();
+            df = org.ofbiz.base.util.UtilDateTime.DEFAULT_DATE_FORMAT;

          try {
              if (nf != null) {


Reply via email to