ICU-9789 Fix problems that Markus found in review.

X-SVN-Rev: 32950
This commit is contained in:
Mark Davis 2012-12-13 01:26:04 +00:00
parent c716e6b67b
commit 730c1d3815
2 changed files with 7 additions and 7 deletions

View File

@ -1922,7 +1922,7 @@ public class SimpleDateFormat extends DateFormat {
return pos; return pos;
} }
static final UnicodeSet DATE_PATTERN_TYPE = new UnicodeSet("[GyYuUQqMLlwWd]"); static final UnicodeSet DATE_PATTERN_TYPE = new UnicodeSet("[GyYuUQqMLlwWd]").freeze();
/** /**
* Attempt to match the text at a given position against an array of * Attempt to match the text at a given position against an array of

View File

@ -4187,7 +4187,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
} }
} }
static Date NOW = new Date(2012-1900, 12, 15); static Date TEST_DATE = new Date(2012-1900, 1-1, 15); // January 15, 2012
public void TestDotAndAtLeniency() { public void TestDotAndAtLeniency() {
for (ULocale locale : Arrays.asList(ULocale.ENGLISH, ULocale.FRENCH)) { for (ULocale locale : Arrays.asList(ULocale.ENGLISH, ULocale.FRENCH)) {
@ -4199,16 +4199,16 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
for (int timeStyle = DateFormat.FULL; timeStyle <= DateFormat.SHORT; ++timeStyle) { for (int timeStyle = DateFormat.FULL; timeStyle <= DateFormat.SHORT; ++timeStyle) {
DateFormat format = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); DateFormat format = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
DateFormat timeFormat = DateFormat.getTimeInstance(timeStyle, locale); DateFormat timeFormat = DateFormat.getTimeInstance(timeStyle, locale);
String formattedString = format.format(NOW); String formattedString = format.format(TEST_DATE);
tests.add(new Object[]{format, formattedString}); tests.add(new Object[]{format, formattedString});
formattedString = dateFormat.format(NOW) + " " + timeFormat.format(NOW); formattedString = dateFormat.format(TEST_DATE) + " " + timeFormat.format(TEST_DATE);
tests.add(new Object[]{format, formattedString}); tests.add(new Object[]{format, formattedString});
if (formattedString.contains("n ")) { if (formattedString.contains("n ")) { // will add "." after the end of text ending in 'n', like Jan.
tests.add(new Object[]{format, formattedString.replace("n ", "n. ") + "."}); tests.add(new Object[]{format, formattedString.replace("n ", "n. ") + "."});
} }
if (formattedString.contains(". ")) { if (formattedString.contains(". ")) { // will subtract "." at the end of strings.
tests.add(new Object[]{format, formattedString.replace(". ", " ")}); tests.add(new Object[]{format, formattedString.replace(". ", " ")});
} }
} }
@ -4228,7 +4228,7 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
ParsePosition parsePosition = new ParsePosition(0); ParsePosition parsePosition = new ParsePosition(0);
parsePosition.setIndex(0); parsePosition.setIndex(0);
Date parsed = format.parse(formattedString, parsePosition); Date parsed = format.parse(formattedString, parsePosition);
boolean ok = NOW.equals(parsed) && parsePosition.getIndex() == formattedString.length(); boolean ok = TEST_DATE.equals(parsed) && parsePosition.getIndex() == formattedString.length();
if (ok) { if (ok) {
logln(format + "\t" + formattedString); logln(format + "\t" + formattedString);
} else { } else {