mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-4904 calling toLocalizedPattern on a ChineseDateFormat that uses its standard patterns throws an Exception since 'l' is a pattern char but not one of the standard DateFormat pattern chars
X-SVN-Rev: 18765
This commit is contained in:
parent
aa568d1178
commit
fcacfabdcb
2 changed files with 24 additions and 5 deletions
|
@ -1833,6 +1833,25 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
}
|
||||
}
|
||||
|
||||
public void TestChineseDateFormatLocalizedPatternChars() {
|
||||
// jb 4904
|
||||
// make sure we can display localized versions of the chars used in the default
|
||||
// chinese date format patterns
|
||||
Calendar chineseCalendar = new ChineseCalendar();
|
||||
chineseCalendar.setTimeInMillis((new Date()).getTime());
|
||||
SimpleDateFormat longChineseDateFormat =
|
||||
(SimpleDateFormat)chineseCalendar.getDateTimeFormat(DateFormat.LONG, DateFormat.LONG, Locale.CHINA );
|
||||
DateFormatSymbols dfs = new ChineseDateFormatSymbols( chineseCalendar, Locale.CHINA );
|
||||
longChineseDateFormat.setDateFormatSymbols( dfs );
|
||||
// This next line throws the exception
|
||||
try {
|
||||
String longFormatPattern = longChineseDateFormat.toLocalizedPattern();
|
||||
}
|
||||
catch (Exception e) {
|
||||
errln("could not localized pattern: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void TestCoverage() {
|
||||
Date now = new Date();
|
||||
Calendar cal = new GregorianCalendar();
|
||||
|
|
|
@ -1748,11 +1748,11 @@ public class SimpleDateFormat extends DateFormat {
|
|||
inQuote = true;
|
||||
else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
|
||||
int ci = from.indexOf(c);
|
||||
if (ci == -1)
|
||||
throw new IllegalArgumentException("Illegal pattern " +
|
||||
" character '" +
|
||||
c + "'");
|
||||
c = to.charAt(ci);
|
||||
if (ci != -1) {
|
||||
c = to.charAt(ci);
|
||||
}
|
||||
// do not worry on translatepattern if the character is not listed
|
||||
// we do the validity check elsewhere
|
||||
}
|
||||
}
|
||||
result.append(c);
|
||||
|
|
Loading…
Add table
Reference in a new issue