You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/02/12 04:48:38 UTC
svn commit: r620697 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry/corelib/components/DateField.java
test/java/org/apache/tapestry/integration/IntegrationTests.java
Author: hlship
Date: Mon Feb 11 19:48:37 2008
New Revision: 620697
URL: http://svn.apache.org/viewvc?rev=620697&view=rev
Log:
TAPESTRY-2151: Date format used by DateField shows the year as two digits, not four
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java?rev=620697&r1=620696&r2=620697&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/DateField.java Mon Feb 11 19:48:37 2008
@@ -83,7 +83,16 @@
@Inject
private FieldValidationSupport _fieldValidationSupport;
- private final DateFormat _format = new SimpleDateFormat("MM/dd/yy");
+ /**
+ * For output, format nicely and unambiguously as four digits.
+ */
+ private final DateFormat _outputFormat = new SimpleDateFormat("MM/dd/yyyy");
+
+ /**
+ * When the user types a value, they may only type two digits for the year; SimpleDateFormat
+ * will do something reasonable. If they use the popup, it will be unambiguously 4 digits.
+ */
+ private final DateFormat _inputFormat = new SimpleDateFormat("MM/dd/yy");
/**
* The default value is a property of the container whose name matches the component's id. May return null if the
@@ -169,7 +178,7 @@
{
if (_value == null) return "";
- return _format.format(_value);
+ return _outputFormat.format(_value);
}
@Override
@@ -185,7 +194,7 @@
{
if (InternalUtils.isNonBlank(value))
parsedValue =
- _format.parse(value);
+ _inputFormat.parse(value);
}
catch (ParseException ex)
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=620697&r1=620696&r2=620697&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Mon Feb 11 19:48:37 2008
@@ -1145,8 +1145,8 @@
assertTextPresent("Birthday: [12/24/1966]");
assertTextPresent("Impact: [05/28/2046]");
- assertFieldValue("birthday", "12/24/66");
- assertFieldValue("asteroidImpact", "05/28/46");
+ assertFieldValue("birthday", "12/24/1966");
+ assertFieldValue("asteroidImpact", "05/28/2046");
}
/**