36
36
import java .security .AccessController ;
37
37
import java .security .PrivilegedAction ;
38
38
import java .time .LocalDateTime ;
39
+ import java .time .ZoneId ;
39
40
import java .time .ZoneOffset ;
40
41
import java .util .ArrayList ;
41
42
import java .util .Arrays ;
42
43
import java .util .Calendar ;
43
44
import java .util .Collections ;
44
45
import java .util .HashMap ;
45
46
import java .util .List ;
46
- import java .util .Locale ;
47
47
import java .util .Map ;
48
48
import java .util .SimpleTimeZone ;
49
49
import java .util .concurrent .ConcurrentHashMap ;
50
50
import java .util .zip .CRC32 ;
51
51
52
52
import jdk .internal .util .StaticProperty ;
53
- import sun .security .action .GetPropertyAction ;
54
53
55
54
/**
56
55
* Loads TZDB time-zone rules for j.u.TimeZone
@@ -65,19 +64,12 @@ public final class ZoneInfoFile {
65
64
* @return a set of time zone IDs.
66
65
*/
67
66
public static String [] getZoneIds () {
68
- int len = regions .length + oldMappings .length ;
69
- if (!USE_OLDMAPPING ) {
70
- len += 3 ; // EST/HST/MST not in tzdb.dat
71
- }
67
+ var shortIDs = ZoneId .SHORT_IDS .keySet ();
68
+ int len = regions .length + shortIDs .size ();
72
69
String [] ids = Arrays .copyOf (regions , len );
73
70
int i = regions .length ;
74
- if (!USE_OLDMAPPING ) {
75
- ids [i ++] = "EST" ;
76
- ids [i ++] = "HST" ;
77
- ids [i ++] = "MST" ;
78
- }
79
- for (int j = 0 ; j < oldMappings .length ; j ++) {
80
- ids [i ++] = oldMappings [j ][0 ];
71
+ for (var id : shortIDs ) {
72
+ ids [i ++] = id ;
81
73
}
82
74
return ids ;
83
75
}
@@ -216,42 +208,7 @@ private ZoneInfoFile() {
216
208
private static String [] regions ;
217
209
private static int [] indices ;
218
210
219
- // Flag for supporting JDK backward compatible IDs, such as "EST".
220
- private static final boolean USE_OLDMAPPING ;
221
-
222
- private static final String [][] oldMappings = new String [][] {
223
- { "ACT" , "Australia/Darwin" },
224
- { "AET" , "Australia/Sydney" },
225
- { "AGT" , "America/Argentina/Buenos_Aires" },
226
- { "ART" , "Africa/Cairo" },
227
- { "AST" , "America/Anchorage" },
228
- { "BET" , "America/Sao_Paulo" },
229
- { "BST" , "Asia/Dhaka" },
230
- { "CAT" , "Africa/Harare" },
231
- { "CNT" , "America/St_Johns" },
232
- { "CST" , "America/Chicago" },
233
- { "CTT" , "Asia/Shanghai" },
234
- { "EAT" , "Africa/Addis_Ababa" },
235
- { "ECT" , "Europe/Paris" },
236
- { "IET" , "America/Indiana/Indianapolis" },
237
- { "IST" , "Asia/Kolkata" },
238
- { "JST" , "Asia/Tokyo" },
239
- { "MIT" , "Pacific/Apia" },
240
- { "NET" , "Asia/Yerevan" },
241
- { "NST" , "Pacific/Auckland" },
242
- { "PLT" , "Asia/Karachi" },
243
- { "PNT" , "America/Phoenix" },
244
- { "PRT" , "America/Puerto_Rico" },
245
- { "PST" , "America/Los_Angeles" },
246
- { "SST" , "Pacific/Guadalcanal" },
247
- { "VST" , "Asia/Ho_Chi_Minh" },
248
- };
249
-
250
211
static {
251
- String oldmapping = GetPropertyAction
252
- .privilegedGetProperty ("sun.timezone.ids.oldmapping" , "false" )
253
- .toLowerCase (Locale .ROOT );
254
- USE_OLDMAPPING = (oldmapping .equals ("yes" ) || oldmapping .equals ("true" ));
255
212
loadTZDB ();
256
213
}
257
214
@@ -274,24 +231,6 @@ public Void run() {
274
231
});
275
232
}
276
233
277
- private static void addOldMapping () {
278
- for (String [] alias : oldMappings ) {
279
- aliases .put (alias [0 ], alias [1 ]);
280
- }
281
- if (USE_OLDMAPPING ) {
282
- aliases .put ("EST" , "America/New_York" );
283
- aliases .put ("MST" , "America/Denver" );
284
- } else {
285
- aliases .put ("EST" , "America/Panama" );
286
- aliases .put ("MST" , "America/Phoenix" );
287
- }
288
- aliases .put ("HST" , "Pacific/Honolulu" );
289
- }
290
-
291
- public static boolean useOldMapping () {
292
- return USE_OLDMAPPING ;
293
- }
294
-
295
234
/**
296
235
* Loads the rules from a DateInputStream
297
236
*
@@ -350,7 +289,7 @@ private static void load(DataInputStream dis) throws IOException {
350
289
}
351
290
}
352
291
// old us time-zone names
353
- addOldMapping ( );
292
+ aliases . putAll ( ZoneId . SHORT_IDS );
354
293
}
355
294
356
295
/////////////////////////Ser/////////////////////////////////
0 commit comments