svn commit: r1751028 - in /ofbiz/trunk: framework/base/src/org/ofbiz/base/conversion/ framework/base/src/org/ofbiz/base/util/ framework/base/src/org/ofbiz/base/util/string/ framework/minilang/src/org/ofbiz/minilang/method/envops/ framework/widget/src/o...

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

svn commit: r1751028 - in /ofbiz/trunk: framework/base/src/org/ofbiz/base/conversion/ framework/base/src/org/ofbiz/base/util/ framework/base/src/org/ofbiz/base/util/string/ framework/minilang/src/org/ofbiz/minilang/method/envops/ framework/widget/src/o...

Arun Patidar-4
Author: arunpatidar
Date: Sat Jul  2 06:16:52 2016
New Revision: 1751028

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

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/base/src/org/ofbiz/base/util/string/UelFunctions.java
    ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.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=1751028&r1=1751027&r2=1751028&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 Sat Jul  2 06:16:52 2016
@@ -68,7 +68,7 @@ public class DateTimeConverters implemen
         public String convert(Calendar obj) throws ConversionException {
             Locale locale = obj.getLocale(com.ibm.icu.util.ULocale.VALID_LOCALE).toLocale();
             TimeZone timeZone = UtilDateTime.toTimeZone(obj.getTimeZone().getID());
-            DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, locale);
+            DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.getDateTimeFormat(), timeZone, locale);
             return df.format(obj);
         }
     }
@@ -155,7 +155,7 @@ public class DateTimeConverters implemen
         public String convert(java.util.Date obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException {
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, locale);
+                df = UtilDateTime.toDateTimeFormat(UtilDateTime.getDateTimeFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toDateTimeFormat(formatString, timeZone, locale);
             }
@@ -386,7 +386,7 @@ public class DateTimeConverters implemen
         public String convert(java.sql.Date obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException {
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, locale);
+                df = UtilDateTime.toDateFormat(UtilDateTime.getDateFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toDateFormat(formatString, timeZone, locale);
             }
@@ -459,7 +459,7 @@ public class DateTimeConverters implemen
         public String convert(java.sql.Time obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException {
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, locale);
+                df = UtilDateTime.toTimeFormat(UtilDateTime.getTimeFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toTimeFormat(formatString, timeZone, locale);
             }
@@ -487,7 +487,7 @@ public class DateTimeConverters implemen
             }
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, locale);
+                df = UtilDateTime.toDateTimeFormat(UtilDateTime.getDateTimeFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toDateTimeFormat(formatString, timeZone, locale);
             }
@@ -512,7 +512,7 @@ public class DateTimeConverters implemen
             }
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toDateTimeFormat(obj.contains("-") ? UtilDateTime.DATE_TIME_FORMAT : null, timeZone, locale);
+                df = UtilDateTime.toDateTimeFormat(obj.contains("-") ? UtilDateTime.getDateTimeFormat() : null, timeZone, locale);
             } else {
                 df = UtilDateTime.toDateTimeFormat(formatString, timeZone, locale);
             }
@@ -570,7 +570,7 @@ public class DateTimeConverters implemen
             }
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, locale);
+                df = UtilDateTime.toDateFormat(UtilDateTime.getDateFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toDateFormat(formatString, timeZone, locale);
             }
@@ -603,7 +603,7 @@ public class DateTimeConverters implemen
             }
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, locale);
+                df = UtilDateTime.toTimeFormat(UtilDateTime.getTimeFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toTimeFormat(formatString, timeZone, locale);
             }
@@ -649,7 +649,7 @@ public class DateTimeConverters implemen
                         str = str + "000".substring(timeSplit[1].length());
                     }
                 }
-                df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, locale);
+                df = UtilDateTime.toDateTimeFormat(UtilDateTime.getDateTimeFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toDateTimeFormat(formatString, timeZone, locale);
             }
@@ -759,7 +759,7 @@ public class DateTimeConverters implemen
         public String convert(java.sql.Timestamp obj, Locale locale, TimeZone timeZone, String formatString) throws ConversionException {
             DateFormat df = null;
             if (UtilValidate.isEmpty(formatString)) {
-                df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, locale);
+                df = UtilDateTime.toDateTimeFormat(UtilDateTime.getDateTimeFormat(), timeZone, locale);
             } else {
                 df = UtilDateTime.toDateTimeFormat(formatString, timeZone, locale);
             }

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=1751028&r1=1751027&r2=1751028&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 Sat Jul  2 06:16:52 2016
@@ -37,19 +37,19 @@ import com.ibm.icu.util.Calendar;
 /**
  * Utility class for handling java.util.Date, the java.sql data/time classes and related
  */
-public class UtilDateTime {
-    public static final String[] months = {// // to be translated over CommonMonthName, see example in accounting
+public final class UtilDateTime {
+    private static final String[] months = {// // to be translated over CommonMonthName, see example in accounting
         "January", "February", "March", "April", "May", "June",
         "July", "August", "September", "October", "November",
         "December"
     };
 
-    public static final String[] days = {// to be translated over CommonDayName, see example in accounting
+    private static final String[] days = {// to be translated over CommonDayName, see example in accounting
         "Monday", "Tuesday", "Wednesday",
         "Thursday", "Friday", "Saturday", "Sunday"
     };
 
-    public static final String[][] timevals = {
+    private static final String[][] timevals = {
         {"1000", "millisecond"},
         {"60", "second"},
         {"60", "minute"},
@@ -57,19 +57,21 @@ public class UtilDateTime {
         {"168", "week"}
     };
 
-    public static final DecimalFormat df = new DecimalFormat("0.00;-0.00");
+    private static final DecimalFormat df = new DecimalFormat("0.00;-0.00");
     /**
      * JDBC escape format for java.sql.Date conversions.
      */
-    public static final String DATE_FORMAT = "yyyy-MM-dd";
+    private static final String DATE_FORMAT = "yyyy-MM-dd";
     /**
      * JDBC escape format for java.sql.Timestamp conversions.
      */
-    public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
+    private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
     /**
      * JDBC escape format for java.sql.Time conversions.
      */
-    public static final String TIME_FORMAT = "HH:mm:ss";
+    private static final String TIME_FORMAT = "HH:mm:ss";
+
+    private UtilDateTime() {}
 
     public static double getInterval(Date from, Date thru) {
         return thru != null ? thru.getTime() - from.getTime() : 0;
@@ -1229,4 +1231,16 @@ public class UtilDateTime {
         }
 
     }
+    
+    public static String getDateFormat() {
+        return DATE_FORMAT;
+    }
+
+    public static String getDateTimeFormat() {
+        return DATE_TIME_FORMAT;
+    }
+
+    public static String getTimeFormat() {
+        return TIME_FORMAT;
+    }
 }

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java?rev=1751028&r1=1751027&r2=1751028&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/string/UelFunctions.java Sat Jul  2 06:16:52 2016
@@ -275,7 +275,7 @@ public class UelFunctions {
     }
 
     public static String dateString(Timestamp stamp, TimeZone timeZone, Locale locale) {
-        DateFormat dateFormat = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, locale);
+        DateFormat dateFormat = UtilDateTime.toDateFormat(UtilDateTime.getDateFormat(), timeZone, locale);
         dateFormat.setTimeZone(timeZone);
         return dateFormat.format(stamp);
     }
@@ -299,7 +299,7 @@ public class UelFunctions {
     }
 
     public static String timeString(Timestamp stamp, TimeZone timeZone, Locale locale) {
-        DateFormat dateFormat = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, locale);
+        DateFormat dateFormat = UtilDateTime.toTimeFormat(UtilDateTime.getTimeFormat(), timeZone, locale);
         dateFormat.setTimeZone(timeZone);
         return dateFormat.format(stamp);
     }

Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java?rev=1751028&r1=1751027&r2=1751028&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java Sat Jul  2 06:16:52 2016
@@ -197,7 +197,7 @@ public final class SetCalendar extends M
             if (timeZone == null) {
                 timeZone = TimeZone.getDefault();
             }
-            fromStamp = (Timestamp) MiniLangUtil.convertType(newValue, java.sql.Timestamp.class, locale, timeZone, UtilDateTime.DATE_TIME_FORMAT);
+            fromStamp = (Timestamp) MiniLangUtil.convertType(newValue, java.sql.Timestamp.class, locale, timeZone, UtilDateTime.getDateTimeFormat());
             if (!this.yearsFse.isEmpty()) {
                 years= parseInt(this.yearsFse.expandString(methodContext.getEnvMap()));
             }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java?rev=1751028&r1=1751027&r2=1751028&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java Sat Jul  2 06:16:52 2016
@@ -640,13 +640,13 @@ public final class CommonWidgetModels {
                 if (retVal instanceof Double || retVal instanceof Float || retVal instanceof BigDecimal) {
                     returnValue = retVal.toString();
                 } else if (retVal instanceof java.sql.Date) {
-                    DateFormat df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, null);
+                    DateFormat df = UtilDateTime.toDateFormat(UtilDateTime.getDateFormat(), timeZone, null);
                     returnValue = df.format((java.util.Date) retVal);
                 } else if (retVal instanceof java.sql.Time) {
-                    DateFormat df = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, null);
+                    DateFormat df = UtilDateTime.toTimeFormat(UtilDateTime.getTimeFormat(), timeZone, null);
                     returnValue = df.format((java.util.Date) retVal);
                 } else if (retVal instanceof java.sql.Timestamp) {
-                    DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, null);
+                    DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.getDateTimeFormat(), timeZone, null);
                     returnValue = df.format((java.util.Date) retVal);
                 } else if (retVal instanceof java.util.Date) {
                     DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM dd hh:mm:ss z yyyy", timeZone, null);

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java?rev=1751028&r1=1751027&r2=1751028&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java Sat Jul  2 06:16:52 2016
@@ -343,13 +343,13 @@ public class ModelFormField {
                     nf.setMaximumFractionDigits(10);
                     return nf.format(retVal);
                 } else if (retVal instanceof java.sql.Date) {
-                    DateFormat df = UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, null);
+                    DateFormat df = UtilDateTime.toDateFormat(UtilDateTime.getDateFormat(), timeZone, null);
                     return df.format((java.util.Date) retVal);
                 } else if (retVal instanceof java.sql.Time) {
-                    DateFormat df = UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, null);
+                    DateFormat df = UtilDateTime.toTimeFormat(UtilDateTime.getTimeFormat(), timeZone, null);
                     return df.format((java.util.Date) retVal);
                 } else if (retVal instanceof java.sql.Timestamp) {
-                    DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, null);
+                    DateFormat df = UtilDateTime.toDateTimeFormat(UtilDateTime.getDateTimeFormat(), timeZone, null);
                     return df.format((java.util.Date) retVal);
                 } else if (retVal instanceof java.util.Date) {
                     DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM dd hh:mm:ss z yyyy", timeZone, null);

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java?rev=1751028&r1=1751027&r2=1751028&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreAutoPreferences.java Sat Jul  2 06:16:52 2016
@@ -310,7 +310,7 @@ public class EbayStoreAutoPreferences {
         String isAutoFeedbackReminder = "N";
         int afterDays = 0;
         GenericValue ebayProductStorePref = null;
-        String dateTimeFormat = UtilDateTime.DATE_TIME_FORMAT;
+        String dateTimeFormat = UtilDateTime.getDateTimeFormat();
         SimpleDateFormat formatter = new SimpleDateFormat(dateTimeFormat);
 
         try {