You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2009/10/15 20:14:28 UTC

svn commit: r825597 - /wicket/branches/wicket-1.4.x/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java

Author: jdonnerstag
Date: Thu Oct 15 18:14:28 2009
New Revision: 825597

URL: http://svn.apache.org/viewvc?rev=825597&view=rev
Log:
fixed WICKET-2525: DatePicker consume too much memory

Modified:
    wicket/branches/wicket-1.4.x/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java

Modified: wicket/branches/wicket-1.4.x/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java?rev=825597&r1=825596&r2=825597&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java (original)
+++ wicket/branches/wicket-1.4.x/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java Thu Oct 15 18:14:28 2009
@@ -17,7 +17,6 @@
 package org.apache.wicket.extensions.yui.calendar;
 
 import java.lang.reflect.Method;
-import java.text.DateFormat;
 import java.text.DateFormatSymbols;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -112,14 +111,16 @@
 	 * "selected" property.
 	 */
 	// See wicket-1988: SimpleDateFormat is not thread safe. Do not use static final
-	public final DateFormat FORMAT_DATE = new SimpleDateFormat("MM/dd/yyyy");
+	// See wicket-2525: SimpleDateFormat consumes a lot of memory
+	public static String FORMAT_DATE = "MM/dd/yyyy";
 
 	/**
 	 * For specifying which page (month/year) to show in the calendar, use this format for the date.
 	 * This is to be used together with the property "pagedate"
 	 */
 	// See wicket-1988: SimpleDateFormat is not thread safe. Do not use static final
-	public final DateFormat FORMAT_PAGEDATE = new SimpleDateFormat("MM/yyyy");
+	// See wicket-2525: SimpleDateFormat consumes a lot of memory
+	public static String FORMAT_PAGEDATE = "MM/yyyy";
 
 	private static final ResourceReference YUI = new JavascriptResourceReference(YuiLib.class, "");
 
@@ -402,8 +403,8 @@
 		if (modelObject instanceof Date)
 		{
 			Date date = (Date)modelObject;
-			widgetProperties.put("selected", FORMAT_DATE.format(date));
-			widgetProperties.put("pagedate", FORMAT_PAGEDATE.format(date));
+			widgetProperties.put("selected", new SimpleDateFormat(FORMAT_DATE).format(date));
+			widgetProperties.put("pagedate", new SimpleDateFormat(FORMAT_PAGEDATE).format(date));
 		}
 	}
 
@@ -753,7 +754,11 @@
 		return component.isEnabledInHierarchy();
 	}
 
-
+	/**
+	 * 
+	 * @param map
+	 * @param calendarInit
+	 */
 	private void appendMapping(Map<String, ? > map, StringBuffer calendarInit)
 	{
 		boolean first = true;