svn commit: r1750968 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1750968 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java

Arun Patidar-4
Author: arunpatidar
Date: Fri Jul  1 15:47:16 2016
New Revision: 1750968

URL: http://svn.apache.org/viewvc?rev=1750968&view=rev
Log:
Applied patch from jira issue - OFBIZ-7587 - Enforce noninstantiability to UtilFormatOut class. Thanks Rishi Solanki and  Rohit Koushal for your contribution.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java?rev=1750968&r1=1750967&r2=1750968&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java Fri Jul  1 15:47:16 2016
@@ -29,9 +29,21 @@ import java.util.TimeZone;
 /**
  * General output formatting functions - mainly for helping in JSPs
  */
-public class UtilFormatOut {
+public final class UtilFormatOut {
 
     public static final String module = UtilFormatOut.class.getName();
+    
+    // ------------------- price format handlers -------------------
+    // FIXME: This is not thread-safe! DecimalFormat is not synchronized.
+    private static final DecimalFormat priceDecimalFormat = new DecimalFormat(UtilProperties.getPropertyValue("general", "currency.decimal.format", "#,##0.00"));
+
+    // ------------------- quantity format handlers -------------------
+    private static final DecimalFormat quantityDecimalFormat = new DecimalFormat("#,##0.###");
+
+    // ------------------- percentage format handlers -------------------
+    private static final DecimalFormat percentageDecimalFormat = new DecimalFormat("##0.##%");
+
+    private UtilFormatOut() {}
 
     public static String safeToString(Object obj) {
         if (obj != null) {
@@ -41,10 +53,6 @@ public class UtilFormatOut {
         }
     }
 
-    // ------------------- price format handlers -------------------
-    // FIXME: This is not thread-safe! DecimalFormat is not synchronized.
-    static DecimalFormat priceDecimalFormat = new DecimalFormat(UtilProperties.getPropertyValue("general", "currency.decimal.format", "#,##0.00"));
-
     /** Formats a Double representing a price into a string
      * @param price The price Double to be formatted
      * @return A String with the formatted price
@@ -169,9 +177,6 @@ public class UtilFormatOut {
         return nf.format(amount);
     }
 
-    // ------------------- percentage format handlers -------------------
-    static DecimalFormat percentageDecimalFormat = new DecimalFormat("##0.##%");
-
     /** Formats a Double representing a percentage into a string
      * @param percentage The percentage Double to be formatted
      * @return A String with the formatted percentage
@@ -198,9 +203,6 @@ public class UtilFormatOut {
         return percentageDecimalFormat.format(percentage);
     }
 
-    // ------------------- quantity format handlers -------------------
-    static DecimalFormat quantityDecimalFormat = new DecimalFormat("#,##0.###");
-
     /** Formats an Long representing a quantity into a string
      * @param quantity The quantity Long to be formatted
      * @return A String with the formatted quantity