Skip to content

Commit 5fcd14e

Browse files
authored
Merge pull request #69 from salesforce/fix-exception
fixed IllegalArgumentException
2 parents 2d972b0 + 5e3f4b3 commit 5fcd14e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/com/force/i18n/BaseLocalizer.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,14 @@ Locale overrideDateLocale(Locale aLocale) {
363363
* The MALAYSIA (MY) (ms_MY) locale returns a time format of the form 'hh:mm' making it impossible to differentiate AM/PM
364364
* @return a dateformat with either a 24-hour clock or the necessary AM/PM identifier attached
365365
*/
366-
private static DateFormat checkAM(DateFormat dateFormat, Locale l) {
367-
DateFormat df = dateFormat;
368-
String p = ((SimpleDateFormat)dateFormat).toPattern();
369-
if ((p.indexOf('a') == -1) && (p.indexOf('k') == -1) && (p.indexOf('H') == -1)) {
370-
df = new SimpleDateFormat(p + " a", l);
366+
DateFormat checkAM(DateFormat dateFormat, Locale l) {
367+
SimpleDateFormat df = (SimpleDateFormat)dateFormat;
368+
String p = df.toPattern();
369+
370+
// fix if neither 'H' or 'k' (24-hour) does not present, and if 'a' or 'B'
371+
// (AM/PM notation) doesn't exist. ICU version of SimpleDateFormat may return 'B' for zh-TW
372+
if ((p.indexOf('H') == -1 && p.indexOf('k') == -1) && (p.indexOf('a') == -1 && p.indexOf('B') == -1)) {
373+
df.applyPattern(p + " a");
371374
}
372375
return df;
373376
}

0 commit comments

Comments
 (0)