Author: adrianc
Date: Mon May 19 16:50:14 2008
New Revision: 658045

URL: http://svn.apache.org/viewvc?rev=658045&view=rev
Log:
Locale and Time Zone refactor and bug fixes.

1. Modified the Start class to initialize the JVM default locale and time zone 
- configurable through start.properties. Removed calls to 
UtilDateTime.getDefaultTimeZone() - no longer needed.

2. Changed all calls to ObjectType.simpleTypeConvert(...) that didn't supply 
the necessary Locale and TimeZone objects. This fixes a lot of localization 
issues, https://issues.apache.org/jira/browse/OFBIZ-1696 being one of them.

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java
    
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java
    
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java
    ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java
    ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/start.properties
    ofbiz/trunk/framework/common/config/general.properties
    
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
    
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java
    
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java
    
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ValidateMethodCondition.java
    
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
    
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java
    
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java
    
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
    
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java
    
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
    
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java
    
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java
    ofbiz/trunk/startofbiz.bat

Modified: 
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java 
(original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilDateTime.java 
Mon May 19 16:50:14 2008
@@ -218,7 +218,7 @@
     }
 
     public static java.sql.Timestamp getDayStart(java.sql.Timestamp stamp, int 
daysLater) {
-        return getDayStart(stamp, daysLater, getDefaultTimeZone(), 
Locale.getDefault());
+        return getDayStart(stamp, daysLater, TimeZone.getDefault(), 
Locale.getDefault());
     }
 
     public static java.sql.Timestamp getNextDayStart(java.sql.Timestamp stamp) 
{
@@ -230,7 +230,7 @@
     }
 
     public static java.sql.Timestamp getDayEnd(java.sql.Timestamp stamp, Long 
daysLater) {
-        return getDayEnd(stamp, daysLater, getDefaultTimeZone(), 
Locale.getDefault());
+        return getDayEnd(stamp, daysLater, TimeZone.getDefault(), 
Locale.getDefault());
     }
 
     /**
@@ -251,7 +251,7 @@
         return getYearStart(stamp, daysLater, 0, yearsLater);
     }
     public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, 
int daysLater, int monthsLater, int yearsLater) {
-        return getYearStart(stamp, daysLater, monthsLater, yearsLater, 
getDefaultTimeZone(), Locale.getDefault());
+        return getYearStart(stamp, daysLater, monthsLater, yearsLater, 
TimeZone.getDefault(), Locale.getDefault());
     }
     public static java.sql.Timestamp getYearStart(java.sql.Timestamp stamp, 
Number daysLater, Number monthsLater, Number yearsLater) {
         return getYearStart(stamp, (daysLater == null ? 0 : 
daysLater.intValue()), 
@@ -273,7 +273,7 @@
     }
 
     public static java.sql.Timestamp getMonthStart(java.sql.Timestamp stamp, 
int daysLater, int monthsLater) {
-        return getMonthStart(stamp, daysLater, monthsLater, 
getDefaultTimeZone(), Locale.getDefault());
+        return getMonthStart(stamp, daysLater, monthsLater, 
TimeZone.getDefault(), Locale.getDefault());
     }
 
     /**
@@ -291,11 +291,11 @@
     }
 
     public static java.sql.Timestamp getWeekStart(java.sql.Timestamp stamp, 
int daysLater, int weeksLater) {
-        return getWeekStart(stamp, daysLater, weeksLater, 
getDefaultTimeZone(), Locale.getDefault());
+        return getWeekStart(stamp, daysLater, weeksLater, 
TimeZone.getDefault(), Locale.getDefault());
     }
 
     public static java.sql.Timestamp getWeekEnd(java.sql.Timestamp stamp) {
-        return getWeekEnd(stamp, getDefaultTimeZone(), Locale.getDefault());
+        return getWeekEnd(stamp, TimeZone.getDefault(), Locale.getDefault());
     }
     
     public static java.util.Calendar toCalendar(java.sql.Timestamp stamp) {
@@ -728,7 +728,7 @@
      * @return A int containing the week number
      */
     public static int weekNumber(Timestamp input) {
-        return weekNumber(input, getDefaultTimeZone(), Locale.getDefault());
+        return weekNumber(input, TimeZone.getDefault(), Locale.getDefault());
     }
     
     public static int weekNumber(Timestamp input, int startOfWeek) {
@@ -1058,25 +1058,13 @@
         return availableTimeZoneList;
     }
 
-    protected static TimeZone defaultTimeZone = null;
     /** Returns the OFBiz default TimeZone object. The default time zone is 
configured in
-     * the <code>general.properties</code> file 
(<code>timeZone.default</code>).
+     * the <code>start.properties</code> file 
(<code>ofbiz.timeZone.default</code>).
+     * @deprecated Okay to use TimeZone.getDefault()
      * @see java.util.TimeZone
      */
     public static TimeZone getDefaultTimeZone() {
-        if (defaultTimeZone == null) {
-            synchronized(UtilDateTime.class) {
-                if (defaultTimeZone == null) {
-                    String tzId = UtilProperties.getPropertyValue("general", 
"timeZone.default");
-                    if (UtilValidate.isNotEmpty(tzId)) {
-                        defaultTimeZone = TimeZone.getTimeZone(tzId);
-                    } else {
-                        defaultTimeZone = TimeZone.getDefault();
-                    }
-                }
-            }
-        }
-        return defaultTimeZone;
+        return TimeZone.getDefault();
     }
     
     /** Returns a TimeZone object based upon a time zone ID. Method defaults to
@@ -1085,7 +1073,7 @@
      */
     public static TimeZone toTimeZone(String tzId) {
         if (UtilValidate.isEmpty(tzId)) {
-            return getDefaultTimeZone();
+            return TimeZone.getDefault();
         } else {
             return TimeZone.getTimeZone(tzId);
         }

Modified: 
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java
 (original)
+++ 
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/string/FlexibleStringExpander.java
 Mon May 19 16:50:14 2008
@@ -29,6 +29,7 @@
 
 import org.ofbiz.base.util.BshUtil;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
@@ -85,7 +86,7 @@
      * @return The original String expanded by replacing varaible place 
holders.
      */    
     public String expandString(Map<String, ? extends Object> context) {
-        return this.expandString(context, null);
+        return this.expandString(context, (Locale) context.get("locale"));
     }
     
     /** 
@@ -195,7 +196,7 @@
         if (timeZone == null) {
             timeZone = (TimeZone) context.get("timeZone");
             if (timeZone == null) {
-                timeZone = UtilDateTime.getDefaultTimeZone();
+                timeZone = TimeZone.getDefault();
             }
         }
 
@@ -285,7 +286,11 @@
             try {
                 Object scriptResult = BshUtil.eval(scriptlet, 
UtilMisc.makeMapWritable(context));
                 if (scriptResult != null) {
-                    buffer.append(scriptResult.toString());
+                    try {
+                        
buffer.append(ObjectType.simpleTypeConvert(scriptResult, "String", null, 
(TimeZone) context.get("timeZone"), locale, true));
+                    } catch (Exception e) {
+                        buffer.append(scriptResult);
+                    }
                 } else {
                     Debug.logWarning("BSH scriplet evaluated to null [" + 
scriptlet + "], got no return so inserting nothing.", module);
                 }
@@ -304,7 +309,11 @@
         public void appendElement(StringBuilder buffer, Map<String, ? extends 
Object> context, Locale locale) {
             Object retVal = fma.get(context, locale);
             if (retVal != null) {
-                buffer.append(retVal.toString()); 
+                try {
+                    buffer.append((String) 
ObjectType.simpleTypeConvert(retVal, "String", null, (TimeZone) 
context.get("timeZone"), locale, true));
+                } catch (Exception e) {
+                    buffer.append(retVal);
+                }
             } else {
                 // otherwise do nothing
             }
@@ -380,22 +389,14 @@
             FlexibleMapAccessor fma = new FlexibleMapAccessor(envName);
             Object envVal = fma.get(context, locale);
             if (envVal != null) {
-                if (envVal instanceof java.sql.Date) {
-                    DateFormat df = 
UtilDateTime.toDateFormat(UtilDateTime.DATE_FORMAT, timeZone, null);
-                    targetBuffer.append(df.format((java.util.Date) envVal));
-                } else if (envVal instanceof java.sql.Time) {
-                    DateFormat df = 
UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, timeZone, null);
-                    targetBuffer.append(df.format((java.util.Date) envVal));
-                } else if (envVal instanceof java.sql.Timestamp) {
-                    DateFormat df = 
UtilDateTime.toDateTimeFormat(UtilDateTime.DATE_TIME_FORMAT, timeZone, null);
-                    targetBuffer.append(df.format((java.util.Date) envVal));
-                } else if (envVal instanceof java.util.Date) {
-                    DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM dd 
hh:mm:ss z yyyy", timeZone, null);
-                    targetBuffer.append(df.format((java.util.Date) envVal));
-                } else if (localizeCurrency) {
+                if (localizeCurrency) {
                     targetBuffer.append(UtilFormatOut.formatCurrency(new 
Double(envVal.toString()), currencyCode, locale));
                 } else {
-                    targetBuffer.append(envVal.toString());
+                    try {
+                        
targetBuffer.append(ObjectType.simpleTypeConvert(envVal, "String", null, 
timeZone, locale, true));
+                    } catch (Exception e) {
+                        targetBuffer.append(envVal);
+                    }
                 }
             } else if (envName.equals("ofbiz.home")) { // This is only used in 
case of Geronimo or WASCE using OFBiz multi-instances. It allows to retrieve 
ofbiz.home value set in JVM env
                 String ofbizHome = System.getProperty("ofbiz.home");
@@ -413,7 +414,11 @@
             try {
                 Object scriptResult = BshUtil.eval(scriptlet, 
UtilMisc.makeMapWritable(context));
                 if (scriptResult != null) {
-                    targetBuffer.append(scriptResult.toString());
+                    try {
+                        
targetBuffer.append(ObjectType.simpleTypeConvert(scriptResult, "String", null, 
timeZone, locale, true));
+                    } catch (Exception e) {
+                        targetBuffer.append(scriptResult);
+                    }
                 } else {
                     Debug.logWarning("BSH scriplet evaluated to null [" + 
scriptlet + "], got no return so inserting nothing.", module);
                 }

Modified: 
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java
 (original)
+++ 
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java
 Mon May 19 16:50:14 2008
@@ -222,7 +222,7 @@
 
         TimeZone timeZone = (TimeZone) context.get("timeZone");
         if (timeZone == null) {
-            timeZone = UtilDateTime.getDefaultTimeZone();
+            timeZone = TimeZone.getDefault();
         }
         env.setTimeZone(timeZone);
     }

Modified: ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java 
(original)
+++ ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java Mon 
May 19 16:50:14 2008
@@ -34,7 +34,9 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Properties;
+import java.util.TimeZone;
 
 /**
  * Start - OFBiz Container(s) Startup Class
@@ -641,7 +643,30 @@
 
             // set the property to tell Jetty to use 2.4 SessionListeners
             
System.setProperty("org.mortbay.jetty.servlet.AbstractSessionManager.24SessionDestroyed",
 "true");
+            
+            // set the default locale
+            String localeString = props.getProperty("ofbiz.locale.default");
+            if (localeString != null && localeString.length() > 0) {
+                String args[] = localeString.split("_");
+                switch (args.length) {
+                case 1:
+                    Locale.setDefault(new Locale(args[0]));
+                    break;
+                case 2:
+                    Locale.setDefault(new Locale(args[0], args[1]));
+                    break;
+                case 3:
+                    Locale.setDefault(new Locale(args[0], args[1], args[2]));
+                }
+                System.setProperty("user.language", localeString);
+            }
 
+            // set the default time zone
+            String tzString = props.getProperty("ofbiz.timeZone.default");
+            if (tzString != null && tzString.length() > 0) {
+                TimeZone.setDefault(TimeZone.getTimeZone(tzString));
+            }
+            
             // loader classes
             loaders = new ArrayList<String>();
             int currentPosition = 1;
@@ -752,3 +777,4 @@
 }
 
 
+

Modified: 
ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/start.properties
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/start.properties?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/start.properties 
(original)
+++ ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/start.properties 
Mon May 19 16:50:14 2008
@@ -67,3 +67,9 @@
 
 # --- Tells AWT (i.e. JasperReports/FOP/etc) to not require a head (X11)
 java.awt.headless=true
+
+# -- The default locale for this OFBiz instance.
+ofbiz.locale.default=en
+
+# -- The default time zone for this OFBiz instance.
+#ofbiz.timeZone.default=GMT

Modified: ofbiz/trunk/framework/common/config/general.properties
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/general.properties?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/config/general.properties (original)
+++ ofbiz/trunk/framework/common/config/general.properties Mon May 19 16:50:14 
2008
@@ -34,9 +34,6 @@
 # -- locales made available separated by commas
 #locales.available=en,fr,nl
 
-# -- default Time Zone
-#timeZone.default=GMT
-
 # -- time zone IDs made available separated by commas
 
#timeZones.available=US/Eastern,US/Central,US/Mountain,US/Pacific,US/Alaska,US/Hawaii
 

Modified: 
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java 
(original)
+++ 
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/EntityFinderUtil.java 
Mon May 19 16:50:14 2008
@@ -46,6 +46,7 @@
 import org.ofbiz.entity.condition.EntityJoinOperator;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.model.ModelEntity;
+import org.ofbiz.entity.model.ModelField;
 import org.ofbiz.entity.util.EntityListIterator;
 import org.w3c.dom.Element;
 
@@ -208,7 +209,7 @@
             // don't convert the field to the desired type if this is an IN 
operator and we have a Collection
             if (!(operator == EntityOperator.IN && value instanceof 
Collection)) {
                 // now to a type conversion for the target fieldName
-                value = modelEntity.convertFieldValue(fieldName, value, 
delegator);
+                value = 
modelEntity.convertFieldValue(modelEntity.getField(fieldName), value, 
delegator, context);
             }
             
             if (Debug.verboseOn()) Debug.logVerbose("Got value for fieldName 
[" + fieldName + "]: " + value, module);

Modified: 
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java 
(original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java 
Mon May 19 16:50:14 2008
@@ -25,8 +25,10 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.TimeZone;
 
 import javolution.util.FastList;
 import javolution.util.FastMap;
@@ -1257,7 +1259,7 @@
             String fieldName = modelField.getName();
             Object oldValue = inContext.get(fieldName);
             if (oldValue != null) {
-                inContext.put(fieldName, this.convertFieldValue(modelField, 
oldValue, delegator));
+                inContext.put(fieldName, this.convertFieldValue(modelField, 
oldValue, delegator, inContext));
             }
         }
     }
@@ -1292,6 +1294,36 @@
         }
     }
 
+    /** Convert a field value from one Java data type to another. This is the 
preferred method -
+     * which takes into consideration the user's locale and time zone (for 
conversions that
+     * require them).
+     * @param modelField
+     * @param value
+     * @param delegator
+     * @param context
+     * @return
+     */
+    public Object convertFieldValue(ModelField modelField, Object value, 
GenericDelegator delegator, Map<String, ? extends Object> context) {
+        if (value == null || value == GenericEntity.NULL_FIELD) {
+            return null;
+        }
+        String fieldJavaType = null;
+        try {
+            fieldJavaType = delegator.getEntityFieldType(this, 
modelField.getType()).getJavaType();
+        } catch (GenericEntityException e) {
+            String errMsg = "Could not convert field value: could not find 
Java type for the field: [" + modelField.getName() + "] on the [" + 
this.getEntityName() + "] entity: " + e.toString();
+            Debug.logError(e, errMsg, module);
+            throw new IllegalArgumentException(errMsg);
+        }
+        try {
+            return ObjectType.simpleTypeConvert(value, fieldJavaType, null, 
(TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true);
+        } catch (GeneralException e) {
+            String errMsg = "Could not convert field value for the field: [" + 
modelField.getName() + "] on the [" + this.getEntityName() + "] entity to the 
[" + fieldJavaType + "] type for the value [" + value + "]: " + e.toString();
+            Debug.logError(e, errMsg, module);
+            throw new IllegalArgumentException(errMsg);
+        }
+    }
+
     /**
      * @return Returns the noAutoStamp.
      */

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java
 (original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java
 Mon May 19 16:50:14 2008
@@ -100,7 +100,7 @@
 
                 if (UtilValidate.isNotEmpty(modelParam.type)) {
                     try {
-                        value = ObjectType.simpleTypeConvert(value, 
modelParam.type, null, null, false);
+                        value = ObjectType.simpleTypeConvert(value, 
modelParam.type, null, methodContext.getTimeZone(), methodContext.getLocale(), 
true);
                     } catch (GeneralException e) {
                         String errMsg = "Could not convert field value for the 
parameter/attribute: [" + modelParam.name + "] on the [" + serviceName + "] 
service to the [" + modelParam.type + "] type for the value [" + value + "]: " 
+ e.toString();
                         Debug.logError(e, errMsg, module);

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java
 (original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/RegexpCondition.java
 Mon May 19 16:50:14 2008
@@ -103,7 +103,7 @@
 
         if (fieldVal != null) {
             try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, null);
+                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, methodContext.getTimeZone(), methodContext.getLocale(), true);
             } catch (GeneralException e) {
                 Debug.logError(e, "Could not convert object to String, using 
empty String", module);
             }

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ValidateMethodCondition.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ValidateMethodCondition.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ValidateMethodCondition.java
 (original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/conditional/ValidateMethodCondition.java
 Mon May 19 16:50:14 2008
@@ -98,7 +98,7 @@
 
         if (fieldVal != null) {
             try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, null);
+                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, methodContext.getTimeZone(), methodContext.getLocale(), true);
             } catch (GeneralException e) {
                 Debug.logError(e, "Could not convert object to String, using 
empty String", module);
             }

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
 (original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
 Mon May 19 16:50:14 2008
@@ -18,6 +18,9 @@
  
*******************************************************************************/
 package org.ofbiz.minilang.method.envops;
 
+import java.util.Locale;
+import java.util.TimeZone;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.ObjectType;
@@ -85,7 +88,7 @@
 
         if (UtilValidate.isNotEmpty(this.type)) {
             try {
-                newValue = ObjectType.simpleTypeConvert(newValue, this.type, 
null, null);
+                newValue = ObjectType.simpleTypeConvert(newValue, this.type, 
null, methodContext.getTimeZone(), methodContext.getLocale(), true);
             } catch (GeneralException e) {
                 String errMsg = "Could not convert field value for the field: 
[" + this.field.toString() + "] to the [" + this.type + "] type for the value 
[" + newValue + "]: " + e.toString();
                 Debug.logError(e, errMsg, module);

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java
 (original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java
 Mon May 19 16:50:14 2008
@@ -84,7 +84,7 @@
         String outStr = null;
         try {
             if (UtilValidate.isNotEmpty(format)) {
-                outStr = (String) ObjectType.simpleTypeConvert(obj, 
"java.lang.String", format, methodContext.getLocale());
+                outStr = (String) ObjectType.simpleTypeConvert(obj, "String", 
format, methodContext.getTimeZone(), methodContext.getLocale(), true);
             } else {
                 outStr = obj.toString();
             }

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java
 (original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfRegexp.java
 Mon May 19 16:50:14 2008
@@ -86,7 +86,7 @@
 
         if (fieldVal != null) {
             try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, null);
+                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, methodContext.getTimeZone(), methodContext.getLocale(), true);
             } catch (GeneralException e) {
                 Debug.logError(e, "Could not convert object to String, using 
empty String", module);
             }

Modified: 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java
 (original)
+++ 
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/ifops/IfValidateMethod.java
 Mon May 19 16:50:14 2008
@@ -84,7 +84,7 @@
 
         if (fieldVal != null) {
             try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, null);
+                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, methodContext.getTimeZone(), methodContext.getLocale(), true);
             } catch (GeneralException e) {
                 Debug.logError(e, "Could not convert object to String, using 
empty String", module);
             }

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java 
(original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java Mon 
May 19 16:50:14 2008
@@ -764,7 +764,7 @@
                 timeZone = (TimeZone) source.get("timeZone");
             }
             if (timeZone == null) {
-                timeZone = UtilDateTime.getDefaultTimeZone();
+                timeZone = TimeZone.getDefault();
             }
         }
         

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java 
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java 
Mon May 19 16:50:14 2008
@@ -27,6 +27,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.regex.PatternSyntaxException;
+import java.util.TimeZone;
 
 import org.ofbiz.base.util.BshUtil;
 import org.ofbiz.base.util.Debug;
@@ -145,7 +146,7 @@
 
             if (UtilValidate.isNotEmpty(this.type)) {
                 try {
-                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, null);
+                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, (TimeZone) context.get("timeZone"), (Locale) 
context.get("locale"), true);
                 } catch (GeneralException e) {
                     String errMsg = "Could not convert field value for the 
field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type 
for the value [" + newValue + "]: " + e.toString();
                     Debug.logError(e, errMsg, module);
@@ -470,3 +471,4 @@
     }
 }
 
+

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java 
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java 
Mon May 19 16:50:14 2008
@@ -626,7 +626,7 @@
         Locale locale = (Locale) context.get("locale");
         if (locale == null) locale = Locale.getDefault();
         TimeZone timeZone = (TimeZone) context.get("timeZone");
-        if (timeZone == null) timeZone = UtilDateTime.getDefaultTimeZone();
+        if (timeZone == null) timeZone = TimeZone.getDefault();
         
         // if useRequestParameters is TRUE then parameters will always be 
used, if FALSE then parameters will never be used
         // if isError is TRUE and useRequestParameters is not FALSE (ie is 
null or TRUE) then parameters will be used
@@ -1788,7 +1788,7 @@
                     isoCode = this.currency.expandString(context);
                 }
                 try {
-                    Double parsedRetVal = (Double) 
ObjectType.simpleTypeConvert(retVal, "Double", null, locale, false);
+                    Double parsedRetVal = (Double) 
ObjectType.simpleTypeConvert(retVal, "Double", null, (TimeZone) 
context.get("timeZone"), (Locale) context.get("locale"), true);
                     retVal = UtilFormatOut.formatCurrency(parsedRetVal, 
isoCode, locale, 10); // we set the max to 10 digits as an hack to not round 
numbers in the ui
                 } catch (GeneralException e) {
                     String errMsg = "Error formatting currency value [" + 
retVal + "]: " + e.toString();

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java 
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java 
Mon May 19 16:50:14 2008
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.TimeZone;
 
 import org.ofbiz.base.util.BshUtil;
 import org.ofbiz.base.util.Debug;
@@ -188,7 +189,7 @@
             
             if (UtilValidate.isNotEmpty(this.type)) {
                 try {
-                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, null);
+                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, (TimeZone) context.get("timeZone"), (Locale) 
context.get("locale"), true);
                 } catch (GeneralException e) {
                     String errMsg = "Could not convert field value for the 
field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type 
for the value [" + newValue + "]: " + e.toString();
                     Debug.logError(e, errMsg, module);
@@ -466,3 +467,4 @@
     }
 }
 
+

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java 
(original)
+++ 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java 
Mon May 19 16:50:14 2008
@@ -21,7 +21,9 @@
 import java.lang.reflect.Method;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.TimeZone;
 
 import javolution.util.FastList;
 
@@ -348,7 +350,7 @@
             String fieldString = null;
             if (fieldVal != null) {
                 try {
-                    fieldString = (String) 
ObjectType.simpleTypeConvert(fieldVal, "String", null, null);
+                    fieldString = (String) 
ObjectType.simpleTypeConvert(fieldVal, "String", null, (TimeZone) 
context.get("timeZone"), (Locale) context.get("locale"), true);
                 } catch (GeneralException e) {
                     Debug.logError(e, "Could not convert object to String, 
using empty String", module);
                 }
@@ -512,7 +514,7 @@
 
             String fieldString = null;
             try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, null);
+                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, (TimeZone) context.get("timeZone"), (Locale) 
context.get("locale"), true);
             } catch (GeneralException e) {
                 Debug.logError(e, "Could not convert object to String, using 
empty String", module);
             }
@@ -552,3 +554,4 @@
     }
 }
 
+

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java 
(original)
+++ 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java 
Mon May 19 16:50:14 2008
@@ -26,6 +26,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.regex.PatternSyntaxException;
+import java.util.TimeZone;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSession;
@@ -187,7 +188,7 @@
             
             if (UtilValidate.isNotEmpty(this.type)) {
                 try {
-                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, null); 
+                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, (TimeZone) context.get("timeZone"), (Locale) 
context.get("locale"), true);
                 } catch (GeneralException e) {
                     String errMsg = "Could not convert field value for the 
field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type 
for the value [" + newValue + "]: " + e.toString();
                     Debug.logError(e, errMsg, module);

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java
 (original)
+++ 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java
 Mon May 19 16:50:14 2008
@@ -22,7 +22,9 @@
 import java.lang.reflect.Method;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.TimeZone;
 
 import javolution.util.FastList;
 
@@ -342,7 +344,7 @@
             String fieldString = null;
             if (fieldVal != null) {
                 try {
-                    fieldString = (String) 
ObjectType.simpleTypeConvert(fieldVal, "String", null, null);
+                    fieldString = (String) 
ObjectType.simpleTypeConvert(fieldVal, "String", null, (TimeZone) 
context.get("timeZone"), (Locale) context.get("locale"), true);
                 } catch (GeneralException e) {
                     Debug.logError(e, "Could not convert object to String, 
using empty String", module);
                 }
@@ -506,7 +508,7 @@
 
             String fieldString = null;
             try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, null);
+                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, (TimeZone) context.get("timeZone"), (Locale) 
context.get("locale"), true);
             } catch (GeneralException e) {
                 Debug.logError(e, "Could not convert object to String, using 
empty String", module);
             }
@@ -544,3 +546,4 @@
     }
 }
 
+

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java 
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java 
Mon May 19 16:50:14 2008
@@ -22,8 +22,10 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Locale;
 import java.util.Map;
 import java.util.regex.PatternSyntaxException;
+import java.util.TimeZone;
 
 import org.ofbiz.base.util.BshUtil;
 import org.ofbiz.base.util.Debug;
@@ -140,7 +142,7 @@
             }
             if (UtilValidate.isNotEmpty(this.type)) {
                 try {
-                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, null);
+                    newValue = ObjectType.simpleTypeConvert(newValue, 
this.type, null, (TimeZone) context.get("timeZone"), (Locale) 
context.get("locale"), true);
                 } catch (GeneralException e) {
                     String errMsg = "Could not convert field value for the 
field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type 
for the value [" + newValue + "]: " + e.toString();
                     Debug.logError(e, errMsg, module);

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java 
(original)
+++ 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java 
Mon May 19 16:50:14 2008
@@ -21,7 +21,9 @@
 import java.lang.reflect.Method;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
+import java.util.TimeZone;
 
 import javolution.util.FastList;
 
@@ -255,7 +257,7 @@
             String fieldString = null;
             if (fieldVal != null) {
                 try {
-                    fieldString = (String) 
ObjectType.simpleTypeConvert(fieldVal, "String", null, null);
+                    fieldString = (String) 
ObjectType.simpleTypeConvert(fieldVal, "String", null, (TimeZone) 
context.get("timeZone"), (Locale) context.get("locale"), true);
                 } catch (GeneralException e) {
                     Debug.logError(e, "Could not convert object to String, 
using empty String", module);
                 }
@@ -419,7 +421,7 @@
 
             String fieldString = null;
             try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, null);
+                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, 
"String", null, (TimeZone) context.get("timeZone"), (Locale) 
context.get("locale"), true);
             } catch (GeneralException e) {
                 Debug.logError(e, "Could not convert object to String, using 
empty String", module);
             }
@@ -459,3 +461,4 @@
     }
 }
 
+

Modified: ofbiz/trunk/startofbiz.bat
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/startofbiz.bat?rev=658045&r1=658044&r2=658045&view=diff
==============================================================================
--- ofbiz/trunk/startofbiz.bat (original)
+++ ofbiz/trunk/startofbiz.bat Mon May 19 16:50:14 2008
@@ -19,7 +19,7 @@
 REM #####################################################################
 ECHO ON
 
-"%JAVA_HOME%\bin\java" -Xms256M -Xmx512M -Duser.language=en -jar ofbiz.jar > 
runtime\logs\console.log
+"%JAVA_HOME%\bin\java" -Xms256M -Xmx512M -jar ofbiz.jar > 
runtime\logs\console.log
 
 REM This one is for more of a debugging mode
 REM "%JAVA_HOME%\bin\java" -Xms256M -Xmx512M -Duser.language=en -Xdebug 
-Xnoagent -Djava.compiler=NONE 
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar ofbiz.jar > 
runtime\logs\console.log


Reply via email to