Skip to content

Commit d2571ea

Browse files
committed
8371339: Illegal pattern char 'B' with locale.providers as HOST on macOS for Taiwanese
Reviewed-by: jlu, rriggs
1 parent 705bd6f commit d2571ea

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/java.base/macosx/classes/sun/util/locale/provider/HostLocaleProviderAdapterImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -874,6 +874,17 @@ private static void convert(String calendarType, char cldrLetter, int count, Str
874874
sb.append('\'');
875875
break;
876876

877+
case 'B':
878+
// 'B' character (day period) is not supported by SimpleDateFormat,
879+
// this is a workaround in which 'B' character
880+
// appearing in macos' pattern string (based on LDML) is replaced
881+
// with 'a' character and hence resolved with am/pm strings.
882+
// This workaround is based on the fallback mechanism
883+
// specified in LDML spec for 'B' character, when a locale
884+
// does not have data for day period ('B')
885+
appendN('a', count, sb);
886+
break;
887+
877888
default:
878889
appendN(cldrLetter, count, sb);
879890
break;

0 commit comments

Comments
 (0)