You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by se...@apache.org on 2004/11/25 06:32:42 UTC
cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/services/pull/util DateFormatterTest.java
seade 2004/11/24 21:32:42
Modified: src/java/org/apache/turbine/services/pull/util Tag:
TURBINE_2_3_BRANCH DateFormatter.java
xdocs Tag: TURBINE_2_3_BRANCH changes.xml
Added: src/test/org/apache/turbine/services/pull/util Tag:
TURBINE_2_3_BRANCH DateFormatterTest.java
Log:
Update DateFormatter to use DateFormatUtils from commons lang.
Revision Changes Path
No revision
No revision
1.3.2.4 +15 -14 jakarta-turbine-2/src/java/org/apache/turbine/services/pull/util/DateFormatter.java
Index: DateFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/pull/util/DateFormatter.java,v
retrieving revision 1.3.2.3
retrieving revision 1.3.2.4
diff -u -r1.3.2.3 -r1.3.2.4
--- DateFormatter.java 20 May 2004 03:06:47 -0000 1.3.2.3
+++ DateFormatter.java 25 Nov 2004 05:32:42 -0000 1.3.2.4
@@ -16,25 +16,29 @@
* limitations under the License.
*/
-import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.turbine.Turbine;
import org.apache.turbine.services.pull.ApplicationTool;
/**
* This pull tool is used to format date objects into strings.
*
+ * <p>As this is designed to be used as a gloal scope pull tool it needs to be
+ * threadsafe.
+ *
+ * <p>This is an application pull tool for the template system. You should
+ * <b>not</b> use it in a normal application.
+ *
* @author <a href="mailto:qmccombs@nequalsone.com">Quinton McCombs</a>
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id$
*/
public class DateFormatter
implements ApplicationTool
{
- /** Used for formatting date objects */
- private SimpleDateFormat sdf = new SimpleDateFormat();
-
/** Default date format */
private static final String DATE_FORMAT_DEFAULT = "MM/dd/yyyy";
@@ -63,11 +67,9 @@
}
/**
- * Refresh the application tool. This is
- * necessary for development work where you
- * probably want the tool to refresh itself
- * if it is using configuration information
- * that is typically cached after initialization
+ * Refresh the application tool. This is necessary for development work
+ * where you probably want the tool to refresh itself if it is using
+ * configuration information that is typically cached after initialization.
*/
public void refresh()
{
@@ -89,8 +91,8 @@
* Formats the given date as a String.
*
* @param theDate date to format
- * @param dateFormatString format string to use. See java.text.SimpleDateFormat
- * for details.
+ * @param dateFormatString format string to use. See
+ * java.text.SimpleDateFormat for details.
* @return String value of the date
*/
public String format(Date theDate, String dateFormatString)
@@ -103,8 +105,7 @@
}
else
{
- this.sdf.applyPattern(dateFormatString);
- result = this.sdf.format(theDate);
+ result = DateFormatUtils.format(theDate, dateFormatString);
}
return result;
}
No revision
No revision
1.60.2.24 +3 -0 jakarta-turbine-2/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/xdocs/changes.xml,v
retrieving revision 1.60.2.23
retrieving revision 1.60.2.24
diff -u -r1.60.2.23 -r1.60.2.24
--- changes.xml 8 Nov 2004 22:12:24 -0000 1.60.2.23
+++ changes.xml 25 Nov 2004 05:32:42 -0000 1.60.2.24
@@ -31,6 +31,9 @@
Make the default encoding for incoming requests configureable. This allows you to post
forms from UTF-8 or other encodings into Turbine.
</action>
+ <action type="update" dev="seade">
+ Update DateFormatter to use DateFormatUtils from commons lang.
+ </action>
</release>
<release version="2.3.1" date="2004-10-29">
No revision
No revision
1.1.2.1 +92 -0 jakarta-turbine-2/src/test/org/apache/turbine/services/pull/util/Attic/DateFormatterTest.java
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org