Author: jonesde
Date: Wed Feb 24 02:31:37 2010
New Revision: 915644
URL: http://svn.apache.org/viewvc?rev=915644&view=rev
Log:
Fixed issue where link parameters where not adjusted for TimeZone, though they
are expected to be in the event processing which causes links and such with
times and timestamps, and sometimes dates, to not match what they came from;
now time zone adjustment is done for link parameters
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=915644&r1=915643&r2=915644&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Wed Feb
24 02:31:37 2010
@@ -20,14 +20,19 @@
import java.io.IOException;
import java.io.StringWriter;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.NumberFormat;
import java.util.List;
import java.util.Map;
+import java.util.TimeZone;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilValidate;
@@ -313,8 +318,35 @@
if (this.value != null) {
return this.value.expandString(context);
} else if (this.fromField != null && this.fromField.get(context)
!= null) {
- Object contextVal = this.fromField.get(context);
- return contextVal.toString();
+ Object retVal = this.fromField.get(context);
+
+ if (retVal != null) {
+ TimeZone timeZone = (TimeZone) context.get("timeZone");
+ if (timeZone == null) timeZone = TimeZone.getDefault();
+
+ String returnValue = null;
+ // format string based on the user's time zone (not locale
because these are parameters)
+ 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);
+ returnValue = df.format((java.util.Date) retVal);
+ } else if (retVal instanceof java.sql.Time) {
+ DateFormat df =
UtilDateTime.toTimeFormat(UtilDateTime.TIME_FORMAT, 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);
+ 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);
+ returnValue = df.format((java.util.Date) retVal);
+ } else {
+ returnValue = retVal.toString();
+ }
+ return returnValue;
+ } else {
+ return null;
+ }
} else {
// as a last chance try finding a context field with the key
of the name field
Object obj = context.get(this.name);