webwork/src/main/webwork/view/taglib TextTag.java,1.11,1.12

[email protected] Fri, 3 Feb 2006 12:36:32 +0000 (UTC)
Newsgroups gmane.comp.java.open-symphony.cvs
Message-ID <[email protected]>
Update of /cvsroot/opensymphony/webwork/src/main/webwork/view/taglib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30953/src/main/webwork/view/taglib

Modified Files:
	TextTag.java 
Log Message:
Add handling for timezones


Index: TextTag.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/view/taglib/TextTag.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- TextTag.java	5 Dec 2005 15:10:19 -0000	1.11
+++ TextTag.java	3 Feb 2006 12:29:47 -0000	1.12
@@ -15,6 +15,7 @@
 import java.util.ArrayList;
 import java.util.Locale;
 import java.util.WeakHashMap;
+import java.util.TimeZone;
 import java.io.IOException;
 
 /**
@@ -127,11 +128,13 @@
             // The idea is to try and convert strings into the
             // types of objects that the formatters expects
             // i.e. Numbers and Dates
+            boolean usesDates = false;
             Format[] formats = fmt.getFormats();
             for (int i = 0; i < formats.length; i++) {
                Format format = formats[i];
                if (format != null) {
                   if (format instanceof DateFormat) {
+                     usesDates = true;
                      if (values.size() > i) {
                         Object value = values.get(i);
                         if (value instanceof String) {
@@ -154,6 +157,19 @@
                }
             }
 
+            // set user timezone on the date formatters if necessary
+            if (usesDates) {
+               TimeZone wwTimezone = (TimeZone) findValue("timezone");
+               if (wwTimezone != null) {
+                  for (int i = 0; i < formats.length; i++) {
+                     Format format = formats[i];
+                     if (format != null && format instanceof DateFormat) {
+                        ((DateFormat) format).setTimeZone(wwTimezone);
+                     }
+                  }
+               }
+            }
+
             String result = fmt.format(values.toArray());
             write(result);
 



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642