You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2009/04/24 10:05:38 UTC

svn commit: r768216 - /wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/converters/SqlTimestampConverter.java

Author: ivaynberg
Date: Fri Apr 24 08:05:38 2009
New Revision: 768216

URL: http://svn.apache.org/viewvc?rev=768216&view=rev
Log:
WICKET-2242
Issue: WICKET-2242

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/converters/SqlTimestampConverter.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/converters/SqlTimestampConverter.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/converters/SqlTimestampConverter.java?rev=768216&r1=768215&r2=768216&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/converters/SqlTimestampConverter.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/converters/SqlTimestampConverter.java Fri Apr 24 08:05:38 2009
@@ -32,6 +32,7 @@
 	private static final long serialVersionUID = 1L;
 
 	private final int dateFormat;
+	private final int timeFormat;
 
 	/**
 	 * Construct.
@@ -39,6 +40,7 @@
 	public SqlTimestampConverter()
 	{
 		dateFormat = DateFormat.SHORT;
+		timeFormat = DateFormat.SHORT;
 	}
 
 	/**
@@ -50,9 +52,24 @@
 	public SqlTimestampConverter(int dateFormat)
 	{
 		this.dateFormat = dateFormat;
+		timeFormat = DateFormat.SHORT;
 	}
 
 	/**
+	 * Construct.
+	 * 
+	 * @param dateFormat
+	 *            See java.text.DateFormat for details. Defaults to DateFormat.SHORT * @param
+	 *            timeFormat See java.text.DateFormat for details. Defaults to DateFormat.SHORT
+	 */
+	public SqlTimestampConverter(int dateFormat, int timeFormat)
+	{
+		this.dateFormat = dateFormat;
+		this.timeFormat = timeFormat;
+	}
+
+
+	/**
 	 * 
 	 * @see org.apache.wicket.util.convert.IConverter#convertToObject(java.lang.String,
 	 *      java.util.Locale)
@@ -69,7 +86,7 @@
 			locale = Locale.getDefault();
 		}
 
-		DateFormat format = DateFormat.getTimeInstance(dateFormat, locale);
+		DateFormat format = DateFormat.getDateTimeInstance(dateFormat, timeFormat, locale);
 		try
 		{
 			Date date = format.parse(value);
@@ -101,7 +118,7 @@
 		}
 
 		Timestamp timestamp = (Timestamp)value;
-		DateFormat format = DateFormat.getTimeInstance(dateFormat, locale);
+		DateFormat format = DateFormat.getDateTimeInstance(dateFormat, timeFormat, locale);
 		return format.format(timestamp);
 	}