4855N/A * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <code>ZoneInfoFile</code> reads Zone information files in the 0N/A * <java.home>/lib/zi directory and provides time zone 0N/A * information in the form of a {@link ZoneInfo} object. Also, it 0N/A * reads the ZoneInfoMappings file to obtain time zone IDs information 0N/A * that is used by the {@link ZoneInfo} class. The directory layout 0N/A * and data file formats are as follows. 0N/A * <p><strong>Directory layout</strong><p> 0N/A * All zone data files and ZoneInfoMappings are put under the 0N/A * <java.home>/lib/zi directory. A path name for a given time 0N/A * zone ID is a concatenation of <java.home>/lib/zi/ and the 0N/A * time zone ID. (The file separator is replaced with the platform 0N/A * dependent value. e.g., '\' for Win32.) An example layout will look 0N/A * A zone data file has specific information of each zone. 0N/A * <code>ZoneInfoMappings</code> has global information of zone IDs so 0N/A * that the information can be obtained without instantiating all time 0N/A * <p><strong>File format</strong><p> 0N/A * Two binary-file formats based on a simple Tag-Length-Value format are used 0N/A * to describe TimeZone information. The generic format of a data file is: 0N/A * where <code>magic</code> is a magic number identifying a file 0N/A * format, <code>version</code> is the format version number, and 0N/A * <code>data</code> is one or more <code>data_item</code>s. The 0N/A * <code>data_item</code> structure is: 0N/A * where <code>tag</code> indicates the data type of the item, 0N/A * <code>length</code> is a byte count of the following 0N/A * <code>value</code> that is the content of item data. 0N/A * All data is stored in the big-endian order. There is no boundary 0N/A * alignment between date items. 0N/A * <p><strong>1. ZoneInfo data file</strong><p> 0N/A * Each ZoneInfo data file consists of the following members. 0N/A * ZoneInfoDataFile { 0N/A * SET OF<sup>1</sup> { 0N/A * transition transitions<sup>2</sup>; 0N/A * offset_table offsets<sup>2</sup>; 0N/A * simpletimezone stzparams<sup>2</sup>; 0N/A * raw_offset rawoffset; 0N/A * gmtoffsetwillchange gmtflag<sup>2</sup>; 0N/A * 1: an unordered collection of zero or one occurrences of each item 0N/A * <code>magic</code> is a byte-string constant identifying the 0N/A * ZoneInfo data file. This field must be <code>"javazi\0"</code> 0N/A * defined as {@link #JAVAZI_LABEL}. 0N/A * <code>version</code> is the version number of the file format. This 0N/A * will be used for compatibility check. This field must be 0N/A * <code>0x01</code> in this version. 0N/A * <code>transition</code>, <code>offset_table</code> and 0N/A * <code>simpletimezone</code> have information of time transition 0N/A * from the past to the future. Therefore, these structures don't 0N/A * exist if the zone didn't change zone names and haven't applied DST in 0N/A * the past, and haven't planned to apply it. (e.g. Asia/Tokyo zone) 0N/A * <code>raw_offset</code>, <code>dstsaving</code> and <code>checksum</code> 0N/A * exist in every zoneinfo file. They are used by TimeZone.class indirectly. 0N/A * <p><strong>1.1 <code>transition</code> structure</strong><p><a name="transition"></a> 0N/A * u1 tag; // 0x04 : constant 0N/A * u2 length; // byte length of whole values 0N/A * s8 value[length/8]; // transitions in `long' 0N/A * See {@link ZoneInfo#transitions ZoneInfo.transitions} about the value. 0N/A * <p><strong>1.2 <code>offset_table</code> structure</strong><p> 0N/A * u1 tag; // 0x05 : constant 0N/A * u2 length; // byte length of whole values 0N/A * s4 value[length/4]; // offset values in `int' 0N/A * <p><strong>1.3 <code>simpletimezone</code> structure</strong><p> 0N/A * See {@link ZoneInfo#simpleTimeZoneParams ZoneInfo.simpleTimeZoneParams} 0N/A * u1 tag; // 0x06 : constant 0N/A * u2 length; // byte length of whole values 0N/A * s4 value[length/4]; // SimpleTimeZone parameters 0N/A * See {@link ZoneInfo#offsets ZoneInfo.offsets} about the value. 0N/A * <p><strong>1.4 <code>raw_offset</code> structure</strong><p> 0N/A * u1 tag; // 0x01 : constant 0N/A * u2 length; // must be 4. 0N/A * s4 value; // raw GMT offset [millisecond] 0N/A * See {@link ZoneInfo#rawOffset ZoneInfo.rawOffset} about the value. 0N/A * <p><strong>1.5 <code>dstsaving</code> structure</strong><p> 0N/A * Value has dstSaving in seconds. 0N/A * u1 tag; // 0x02 : constant 0N/A * u2 length; // must be 2. 0N/A * s2 value; // DST save value [second] 0N/A * See {@link ZoneInfo#dstSavings ZoneInfo.dstSavings} about value. 0N/A * <p><strong>1.6 <code>checksum</code> structure</strong><p> 0N/A * u1 tag; // 0x03 : constant 0N/A * u2 length; // must be 4. 0N/A * s4 value; // CRC32 value of transitions 0N/A * See {@link ZoneInfo#checksum ZoneInfo.checksum}. 0N/A * <p><strong>1.7 <code>gmtoffsetwillchange</code> structure</strong><p> 0N/A * This record has a flag value for {@link ZoneInfo#rawOffsetWillChange}. 0N/A * If this record is not present in a zoneinfo file, 0 is assumed for 0N/A * gmtoffsetwillchange { 0N/A * u1 tag; // 0x07 : constant 0N/A * u2 length; // must be 1. 0N/A * u1 value; // 1: if the GMT raw offset will change 0N/A * // in the future, 0, otherwise. 0N/A * <p><strong>2. ZoneInfoMappings file</strong><p> 0N/A * The ZoneInfoMappings file consists of the following members. 0N/A * ZoneInfoMappings { 0N/A * versionName version; 0N/A * zone_id_table zoneIDs; 0N/A * raw_offset_table rawoffsets; 0N/A * raw_offset_index_table rawoffsetindices; 0N/A * alias_table aliases; 0N/A * excluded_list excludedList; 0N/A * <code>magic</code> is a byte-string constant which has the file type. 0N/A * This field must be <code>"javazm\0"</code> defined as {@link #JAVAZM_LABEL}. 0N/A * <code>version</code> is the version number of this file 0N/A * format. This will be used for compatibility check. This field must 0N/A * be <code>0x01</code> in this version. 0N/A * <code>versionName</code> shows which version of Olson's data has been used 0N/A * to generate this ZoneInfoMappings. (e.g. <code>tzdata2000g</code>) <br> 0N/A * This field is for trouble-shooting and isn't usually used in runtime. 0N/A * <code>zone_id_table</code>, <code>raw_offset_index_table</code> and 0N/A * <code>alias_table</code> are general information of supported 0N/A * <p><strong>2.1 <code>zone_id_table</code> structure</strong><p> 0N/A * The list of zone IDs included in the zi database. The list does 0N/A * <em>not</em> include zone IDs, if any, listed in excludedList. 0N/A * u1 tag; // 0x40 : constant 0N/A * u2 length; // byte length of whole values 0N/A * zone_id value[zone_id_count]; 0N/A * u1 byte_length; // byte length of id 0N/A * u1 id[byte_length]; // zone name string 0N/A * <p><strong>2.2 <code>raw_offset_table</code> structure</strong><p> 0N/A * raw_offset_table { 0N/A * u1 tag; // 0x41 : constant 0N/A * u2 length; // byte length of whole values 0N/A * s4 value[length/4]; // raw GMT offset in milliseconds 0N/A * <p><strong>2.3 <code>raw_offset_index_table</code> structure</strong><p> 0N/A * raw_offset_index_table { 0N/A * u1 tag; // 0x42 : constant 0N/A * u2 length; // byte length of whole values 0N/A * <p><strong>2.4 <code>alias_table</code> structure</strong><p> 0N/A * u1 tag; // 0x43 : constant 0N/A * u2 length; // byte length of whole values 0N/A * u2 nentries; // number of id-pairs 0N/A * id_pair value[nentries]; 0N/A * zone_id aliasname; 0N/A * <p><strong>2.5 <code>versionName</code> structure</strong><p> 0N/A * u1 tag; // 0x44 : constant 0N/A * u2 length; // byte length of whole values 0N/A * <p><strong>2.6 <code>excludeList</code> structure</strong><p> 0N/A * The list of zone IDs whose zones will change their GMT offsets 0N/A * (a.k.a. raw offsets) some time in the future. Those IDs must be 0N/A * added to the list of zone IDs for getAvailableIDs(). Also they must 0N/A * be examined for getAvailableIDs(int) to determine the 0N/A * <em>current</em> GMT offsets. 0N/A * u1 tag; // 0x45 : constant 0N/A * u2 length; // byte length of whole values 0N/A * u2 nentries; // number of zone_ids 0N/A * zone_id value[nentries]; // excluded zone IDs 0N/A * The magic number for the ZoneInfo data file format. 0N/A (
byte)
'j', (
byte)
'a', (
byte)
'v', (
byte)
'a', (
byte)
'z', (
byte)
'i', (
byte)
'\0' 0N/A * The ZoneInfo data file format version number. Must increase 0N/A * one when any incompatible change has been made. 0N/A * Raw offset data item tag. 0N/A * Known last Daylight Saving Time save value data item tag. 0N/A * Checksum data item tag. 0N/A * Transition data item tag. 0N/A * Offset table data item tag. 0N/A * SimpleTimeZone parameters data item tag. 0N/A * Raw GMT offset will change in the future. 0N/A * The ZoneInfoMappings file name. 0N/A * The magic number for the ZoneInfoMappings file format. 0N/A (
byte)
'j', (
byte)
'a', (
byte)
'v', (
byte)
'a', (
byte)
'z', (
byte)
'm', (
byte)
'\0' 0N/A * The ZoneInfoMappings file format version number. Must increase 0N/A * one when any incompatible change has been made. 0N/A * Time zone IDs data item tag. 0N/A * Raw GMT offsets table data item tag. 0N/A * Indices to the raw GMT offset table data item tag. 0N/A * Time zone aliases table data item tag. 0N/A * Olson's public zone information version tag. 0N/A * Excluded zones item tag. (Added in Mustang) 0N/A * Converts the given time zone ID to a platform dependent path 0N/A * "America\Los_Angeles" on Win32. 0N/A * @return a modified ID replacing '/' with {@link 0N/A * java.io.File#separatorChar File.separatorChar} if needed. 0N/A * Gets a ZoneInfo with the given GMT offset. The object 0N/A * has its ID in the format of GMT{+|-}hh:mm. 0N/A * @param originalId the given custom id (before normalized such as "GMT+9") 0N/A * @param gmtOffset GMT offset <em>in milliseconds</em> 0N/A * @return a ZoneInfo constructed with the given GMT offset 0N/A char[]
buf =
new char[] {
'G',
'M',
'T',
sign,
'0',
'0',
':',
'0',
'0' };
0N/A * @return a ZoneInfo instance created for the specified id, or 0N/A * null if there is no time zone data file found for the specified 4855N/A //treat GMT zone as special 0N/A for (
int i =
0; i < n; i ++) {
0N/A for (
int i =
0; i < n; i ++) {
0N/A for (
int i =
0; i < n; i++) {
0N/A for (
int i =
0; i < n; i++) {
0N/A * @return an alias table in HashMap where a key is an alias ID 0N/A * (e.g., "PST") and its value is a real time zone ID (e.g., 0N/A for (
int i =
0; i < n; i++) {
0N/A * @return a List of zone IDs for zones that will change their GMT 0N/A * offsets in some future time. 0N/A for (
int i =
0; i < n; i++) {
0N/A for (
int i =
0; i <
len; i++) {
0N/A for (
int i =
0; i < n; i++) {
0N/A * Reads the specified file under <java.home>/lib/zi into a buffer. 0N/A * @return the buffer, or null if any I/O error occurred.