Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation.
()
| 102 | * Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation. |
| 103 | */ |
| 104 | public static java.util.TimeZone getDefault(){ |
| 105 | if (defaultTimeZone == null) { |
| 106 | final String tzone = getTimezoneId(); |
| 107 | defaultTimeZone = new TimeZone() { |
| 108 | @Override |
| 109 | public int getOffset(int era, int year, int month, int day, int dayOfWeek, int timeOfDayMillis) { |
| 110 | return getTimezoneOffset(tzone, year, month + 1, day, timeOfDayMillis); |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public int getRawOffset() { |
| 115 | return getTimezoneRawOffset(tzone); |
| 116 | } |
| 117 | |
| 118 | boolean inDaylightTime(Date time) { |
| 119 | return isTimezoneDST(tzone, time.getTime()); |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public boolean useDaylightTime() { |
| 124 | return isTimezoneDST(tzone, getDec30()) != isTimezoneDST(tzone, getJuly1()); // 26 weeks |
| 125 | } |
| 126 | }; |
| 127 | defaultTimeZone.ID = tzone; |
| 128 | } |
| 129 | return defaultTimeZone; |
| 130 | } |
| 131 | |
| 132 | public static void setDefault(TimeZone timezone) { |
| 133 | defaultTimeZone = timezone; |