diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-08-24 12:23:04 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-08-24 12:23:04 +0000 |
commit | b886cf2165451fe0443a253be37cfca50122d80e (patch) | |
tree | 4bddd55b16dedb01fd6306e2788ff604b387d87f /src/com | |
parent | 0cb9b8bc806f30ae2eb91c8ab1215a8b61871229 (diff) | |
download | vaadin-framework-b886cf2165451fe0443a253be37cfca50122d80e.tar.gz vaadin-framework-b886cf2165451fe0443a253be37cfca50122d80e.zip |
Fix for #5475 - DateField text field includes extra single quote in some cases
Extended test case to cover #5475
svn changeset:14579/svn branch:6.4
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/DateTimeService.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/DateTimeService.java b/src/com/vaadin/terminal/gwt/client/DateTimeService.java index b307eaf737..dffe2a9a53 100644 --- a/src/com/vaadin/terminal/gwt/client/DateTimeService.java +++ b/src/com/vaadin/terminal/gwt/client/DateTimeService.java @@ -313,6 +313,16 @@ public class DateTimeService { String monthName = getMonth(date.getMonth());
if (monthName != null) {
+ /*
+ * Replace 4 or more M:s with the quoted month name. Also
+ * concatenate generated string with any other string prepending
+ * or following the MMMM pattern, i.e. 'MMMM'ta ' becomes
+ * 'MONTHta ' and not 'MONTH''ta ', 'ab'MMMM becomes 'abMONTH',
+ * 'x'MMMM'y' becomes 'xMONTHy'.
+ */
+ formatStr = formatStr.replaceAll("'([M]{4,})'", monthName);
+ formatStr = formatStr.replaceAll("([M]{4,})'", "'" + monthName);
+ formatStr = formatStr.replaceAll("'([M]{4,})", monthName + "'");
formatStr = formatStr.replaceAll("[M]{4,}", "'" + monthName
+ "'");
}
@@ -324,6 +334,16 @@ public class DateTimeService { String monthName = getShortMonth(date.getMonth());
if (monthName != null) {
+ /*
+ * Replace 3 or more M:s with the quoted month name. Also
+ * concatenate generated string with any other string prepending
+ * or following the MMM pattern, i.e. 'MMM'ta ' becomes 'MONTHta
+ * ' and not 'MONTH''ta ', 'ab'MMM becomes 'abMONTH', 'x'MMM'y'
+ * becomes 'xMONTHy'.
+ */
+ formatStr = formatStr.replaceAll("'([M]{3,})'", monthName);
+ formatStr = formatStr.replaceAll("([M]{3,})'", "'" + monthName);
+ formatStr = formatStr.replaceAll("'([M]{3,})", monthName + "'");
formatStr = formatStr.replaceAll("[M]{3,}", "'" + monthName
+ "'");
}
@@ -333,12 +353,15 @@ public class DateTimeService { }
/**
- * Replaces month names in the entered date Parses the month name from the
- * entered dat
+ * Replaces month names in the entered date with the name in the current
+ * browser locale.
*
* @param enteredDate
+ * Date string e.g. "5 May 2010"
* @param formatString
- * @return
+ * Format string e.g. "d M yyyy"
+ * @return The date string where the month names have been replaced by the
+ * browser locale version
*/
private String parseMonthName(String enteredDate, String formatString) {
LocaleInfo browserLocale = LocaleInfo.getCurrentLocale();
|