timezone.java

来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 1,326 行 · 第 1/4 页

JAVA
1,326
字号
	timezones0.put("VST", tz);	timezones0.put("Antarctica/Davis", tz);	timezones0.put("Asia/Bangkok", tz);	timezones0.put("Asia/Hovd", tz);	timezones0.put("Asia/Jakarta", tz);	timezones0.put("Asia/Phnom_Penh", tz);	timezones0.put("Asia/Saigon", tz);	timezones0.put("Asia/Vientiane", tz);	timezones0.put("Indian/Christmas", tz);	tz = new SimpleTimeZone	  (7000 * 3600, "Asia/Krasnoyarsk",	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Asia/Krasnoyarsk", tz);	tz = new SimpleTimeZone(8000 * 3600, "CTT");	timezones0.put("CTT", tz);	timezones0.put("Antarctica/Casey", tz);	timezones0.put("Asia/Brunei", tz);	timezones0.put("Asia/Chungking", tz);	timezones0.put("Asia/Harbin", tz);	timezones0.put("Asia/Hong_Kong", tz);	timezones0.put("Asia/Kashgar", tz);	timezones0.put("Asia/Kuala_Lumpur", tz);	timezones0.put("Asia/Kuching", tz);	timezones0.put("Asia/Macao", tz);	timezones0.put("Asia/Manila", tz);	timezones0.put("Asia/Shanghai", tz);	timezones0.put("Asia/Singapore", tz);	timezones0.put("Asia/Taipei", tz);	timezones0.put("Asia/Ujung_Pandang", tz);	timezones0.put("Asia/Ulaanbaatar", tz);	timezones0.put("Asia/Urumqi", tz);	timezones0.put("Australia/Perth", tz);	tz = new SimpleTimeZone	  (8000 * 3600, "Asia/Irkutsk",	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Asia/Irkutsk", tz);	tz = new SimpleTimeZone(9000 * 3600, "JST");	timezones0.put("JST", tz);	timezones0.put("Asia/Dili", tz);	timezones0.put("Asia/Jayapura", tz);	timezones0.put("Asia/Pyongyang", tz);	timezones0.put("Asia/Seoul", tz);	timezones0.put("Asia/Tokyo", tz);	timezones0.put("Pacific/Palau", tz);	tz = new SimpleTimeZone	  (9000 * 3600, "Asia/Yakutsk",	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Asia/Yakutsk", tz);	tz = new SimpleTimeZone	  (9500 * 3600, "Australia/Adelaide",	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Australia/Adelaide", tz);	timezones0.put("Australia/Broken_Hill", tz);	tz = new SimpleTimeZone(9500 * 3600, "ACT");	timezones0.put("ACT", tz);	timezones0.put("Australia/Darwin", tz);	tz = new SimpleTimeZone(10000 * 3600, "Antarctica/DumontDUrville");	timezones0.put("Antarctica/DumontDUrville", tz);	timezones0.put("Australia/Brisbane", tz);	timezones0.put("Australia/Lindeman", tz);	timezones0.put("Pacific/Guam", tz);	timezones0.put("Pacific/Port_Moresby", tz);	timezones0.put("Pacific/Saipan", tz);	timezones0.put("Pacific/Truk", tz);	timezones0.put("Pacific/Yap", tz);	tz = new SimpleTimeZone	  (10000 * 3600, "Asia/Vladivostok",	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Asia/Vladivostok", tz);	tz = new SimpleTimeZone	  (10000 * 3600, "Australia/Hobart",	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Australia/Hobart", tz);	tz = new SimpleTimeZone	  (10000 * 3600, "AET",	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("AET", tz);	timezones0.put("Australia/Melbourne", tz);	timezones0.put("Australia/Sydney", tz);	tz = new SimpleTimeZone	  (10500 * 3600, "Australia/Lord_Howe",	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600, 500 * 3600);	timezones0.put("Australia/Lord_Howe", tz);	tz = new SimpleTimeZone	  (11000 * 3600, "Asia/Magadan",	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Asia/Magadan", tz);	tz = new SimpleTimeZone(11000 * 3600, "SST");	timezones0.put("SST", tz);	timezones0.put("Pacific/Efate", tz);	timezones0.put("Pacific/Guadalcanal", tz);	timezones0.put("Pacific/Kosrae", tz);	timezones0.put("Pacific/Noumea", tz);	timezones0.put("Pacific/Ponape", tz);	tz = new SimpleTimeZone(11500 * 3600, "Pacific/Norfolk");	timezones0.put("Pacific/Norfolk", tz);	tz = new SimpleTimeZone	  (12000 * 3600, "NST",	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.MARCH, 3, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("NST", tz);	timezones0.put("Antarctica/McMurdo", tz);	timezones0.put("Antarctica/South_Pole", tz);	timezones0.put("Pacific/Auckland", tz);	tz = new SimpleTimeZone	  (12000 * 3600, "Asia/Anadyr",	   Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,	   Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);	timezones0.put("Asia/Anadyr", tz);	timezones0.put("Asia/Kamchatka", tz);	tz = new SimpleTimeZone(12000 * 3600, "Pacific/Fiji");	timezones0.put("Pacific/Fiji", tz);	timezones0.put("Pacific/Funafuti", tz);	timezones0.put("Pacific/Kwajalein", tz);	timezones0.put("Pacific/Majuro", tz);	timezones0.put("Pacific/Nauru", tz);	timezones0.put("Pacific/Tarawa", tz);	timezones0.put("Pacific/Wake", tz);	timezones0.put("Pacific/Wallis", tz);	tz = new SimpleTimeZone	  (12750 * 3600, "Pacific/Chatham",	   Calendar.OCTOBER, 1, Calendar.SUNDAY, 2750 * 3600,	   Calendar.MARCH, 3, Calendar.SUNDAY, 2750 * 3600);	timezones0.put("Pacific/Chatham", tz);	tz = new SimpleTimeZone(13000 * 3600, "Pacific/Enderbury");	timezones0.put("Pacific/Enderbury", tz);	timezones0.put("Pacific/Tongatapu", tz);	tz = new SimpleTimeZone(14000 * 3600, "Pacific/Kiritimati");	timezones0.put("Pacific/Kiritimati", tz);      }    return timezones0;  }  /**   * Maps a time zone name (with optional GMT offset and daylight time   * zone name) to one of the known time zones.  This method called   * with the result of <code>System.getProperty("user.timezone")</code>   * or <code>getDefaultTimeZoneId()</code>.  Note that giving one of   * the standard tz data names from ftp://elsie.nci.nih.gov/pub/ is   * preferred.  The time zone name can be given as follows:   * <code>(standard zone name)[(GMT offset)[(daylight time zone name)]]</code>   * <p>   * If only a (standard zone name) is given (no numbers in the   * String) then it gets mapped directly to the TimeZone with that   * name, if that fails null is returned.   * <p>   * A GMT offset is the offset to add to the local time to get GMT.   * If a (GMT offset) is included (either in seconds or hours) then   * an attempt is made to find a TimeZone name matching both the name   * and the offset (that doesn't observe daylight time, if the   * timezone observes daylight time then you must include a daylight   * time zone name after the offset), if that fails then a TimeZone   * with the given GMT offset is returned (whether or not the   * TimeZone observes daylight time is ignored), if that also fails   * the GMT TimeZone is returned.   * <p>   * If the String ends with (GMT offset)(daylight time zone name)   * then an attempt is made to find a TimeZone with the given name and   * GMT offset that also observes (the daylight time zone name is not   * currently used in any other way), if that fails a TimeZone with   * the given GMT offset that observes daylight time is returned, if   * that also fails the GMT TimeZone is returned.   * <p>   * Examples: In Chicago, the time zone id could be "CST6CDT", but   * the preferred name would be "America/Chicago".  In Indianapolis   * (which does not have Daylight Savings Time) the string could be   * "EST5", but the preferred name would be "America/Indianapolis".   * The standard time zone name for The Netherlands is "Europe/Amsterdam",   * but can also be given as "CET-1CEST".   */  static TimeZone getDefaultTimeZone(String sysTimeZoneId)  {    // First find start of GMT offset info and any Daylight zone name.    int startGMToffset = 0;    int sysTimeZoneIdLength = sysTimeZoneId.length();    for (int i = 0; i < sysTimeZoneIdLength && startGMToffset == 0; i++)      {	char c = sysTimeZoneId.charAt(i);	if (Character.isDigit(c))	  startGMToffset = i;	else if ((c == '+' || c == '-')		 && i + 1 < sysTimeZoneIdLength		 && Character.isDigit(sysTimeZoneId.charAt(i + 1)))	  startGMToffset = i;      }        String tzBasename;    if (startGMToffset == 0)      tzBasename = sysTimeZoneId;    else      tzBasename = sysTimeZoneId.substring (0, startGMToffset);        int startDaylightZoneName = 0;    for (int i = sysTimeZoneIdLength - 1;	 i >= 0 && !Character.isDigit(sysTimeZoneId.charAt(i)); --i)      startDaylightZoneName = i;        boolean useDaylightTime = startDaylightZoneName > 0;        // Integer.parseInt() doesn't handle leading +.    if (sysTimeZoneId.charAt(startGMToffset) == '+')      startGMToffset++;        int gmtOffset = 0;    if (startGMToffset > 0)      {	gmtOffset = Integer.parseInt	  (startDaylightZoneName == 0	   ? sysTimeZoneId.substring(startGMToffset)	   : sysTimeZoneId.substring(startGMToffset,				     startDaylightZoneName));		// Offset could be in hours or seconds.  Convert to millis.	// The offset is given as the time to add to local time to get GMT	// we need the time to add to GMT to get localtime.	if (Math.abs(gmtOffset) < 24)	  gmtOffset *= 60 * 60;	gmtOffset *= -1000;      }        // Try to be optimistic and get the timezone that matches the base name.    // If we only have the base name then just accept this timezone.    // Otherwise check the gmtOffset and day light attributes.    TimeZone tz = (TimeZone) timezones().get(tzBasename);    if (tz != null	&& (tzBasename == sysTimeZoneId	    || (tz.getRawOffset() == gmtOffset		&& tz.useDaylightTime() == useDaylightTime)))      return tz;        // Maybe there is one with the daylight zone name?    if (useDaylightTime)      {	String daylightZoneName;	daylightZoneName = sysTimeZoneId.substring(startDaylightZoneName);	if (!daylightZoneName.equals(tzBasename))	  {	    tz = (TimeZone) timezones().get(tzBasename);	    if (tz != null		&& tz.getRawOffset() == gmtOffset		&& tz.useDaylightTime())	      return tz;	  }      }        // If no match, see if a valid timezone has similar attributes as this    // and then use it instead. We take the first one that looks OKish.    if (startGMToffset > 0)      {	String[] ids = getAvailableIDs(gmtOffset);	for (int i = 0; i < ids.length; i++)	  {	    tz = (TimeZone) timezones().get(ids[i]);	    if (tz.useDaylightTime() == useDaylightTime)	      return tz;	  }      }        return null;  }  /**   * Gets the time zone offset, for current date, modified in case of    * daylight savings.  This is the offset to add to UTC to get the local   * time.   * @param era the era of the given date   * @param year the year of the given date   * @param month the month of the given date, 0 for January.   * @param day the day of month   * @param dayOfWeek the day of week   * @param milliseconds the millis in the day (in local standard time)   * @return the time zone offset in milliseconds.   */  public abstract int getOffset(int era, int year, int month,				int day, int dayOfWeek, int milliseconds);  /**   * Get the time zone offset for the specified date, modified in case of   * daylight savings.  This is the offset to add to UTC to get the local   * time.   * @param date the date represented in millisecends   * since January 1, 1970 00:00:00 GMT.   * @since 1.4   */  public int getOffset(long date)  {    return (inDaylightTime(new Date(date))            ? getRawOffset() + getDSTSavings()            : getRawOffset());  }    /**   * Gets the time zone offset, ignoring daylight savings.  This is   * the offset to add to UTC to get the local time.   * @return the time zone offset in milliseconds.     */  public abstract int getRawOffset();  /**   * Sets the time zone offset, ignoring daylight savings.  This is   * the offset to add to UTC to get the local time.   * @param offsetMillis the time zone offset to GMT.   */  public abstract void setRawOffset(int offsetMillis);  /**   * Gets the identifier of this time zone. For instance, PST for   * Pacific Standard Time.   * @returns the ID of this time zone.     */  public String getID()  {    return ID;  }  /**   * Sets the identifier of this time zone. For instance, PST for   * Pacific Standard Time.   * @param id the new time zone ID.   * @throws NullPointerException if <code>id</code> is <code>null</code>   */  public void setID(String id)  {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?