204 * @param date the date represented in milliseconds since January 1, 1970 00:00:00 GMT
205 * @return the amount of time in milliseconds to add to UTC to get local time.
206 *
207 * @see Calendar#ZONE_OFFSET
208 * @see Calendar#DST_OFFSET
209 * @since 1.4
210 */
211 public int getOffset(long date) {
212 if (inDaylightTime(new Date(date))) {
213 return getRawOffset() + getDSTSavings();
214 }
215 return getRawOffset();
216 }
217
218 /**
219 * Gets the raw GMT offset and the amount of daylight saving of this
220 * time zone at the given time.
221 * @param date the milliseconds (since January 1, 1970,
222 * 00:00:00.000 GMT) at which the time zone offset and daylight
223 * saving amount are found
224 * @param offset an array of int where the raw GMT offset
225 * (offset[0]) and daylight saving amount (offset[1]) are stored,
226 * or null if those values are not needed. The method assumes that
227 * the length of the given array is two or larger.
228 * @return the total amount of the raw GMT offset and daylight
229 * saving at the specified date.
230 *
231 * @see Calendar#ZONE_OFFSET
232 * @see Calendar#DST_OFFSET
233 */
234 int getOffsets(long date, int[] offsets) {
235 int rawoffset = getRawOffset();
236 int dstoffset = 0;
237 if (inDaylightTime(new Date(date))) {
238 dstoffset = getDSTSavings();
239 }
240 if (offsets != null) {
241 offsets[0] = rawoffset;
242 offsets[1] = dstoffset;
243 }
244 return rawoffset + dstoffset;
|
204 * @param date the date represented in milliseconds since January 1, 1970 00:00:00 GMT
205 * @return the amount of time in milliseconds to add to UTC to get local time.
206 *
207 * @see Calendar#ZONE_OFFSET
208 * @see Calendar#DST_OFFSET
209 * @since 1.4
210 */
211 public int getOffset(long date) {
212 if (inDaylightTime(new Date(date))) {
213 return getRawOffset() + getDSTSavings();
214 }
215 return getRawOffset();
216 }
217
218 /**
219 * Gets the raw GMT offset and the amount of daylight saving of this
220 * time zone at the given time.
221 * @param date the milliseconds (since January 1, 1970,
222 * 00:00:00.000 GMT) at which the time zone offset and daylight
223 * saving amount are found
224 * @param offsets an array of int where the raw GMT offset
225 * (offset[0]) and daylight saving amount (offset[1]) are stored,
226 * or null if those values are not needed. The method assumes that
227 * the length of the given array is two or larger.
228 * @return the total amount of the raw GMT offset and daylight
229 * saving at the specified date.
230 *
231 * @see Calendar#ZONE_OFFSET
232 * @see Calendar#DST_OFFSET
233 */
234 int getOffsets(long date, int[] offsets) {
235 int rawoffset = getRawOffset();
236 int dstoffset = 0;
237 if (inDaylightTime(new Date(date))) {
238 dstoffset = getDSTSavings();
239 }
240 if (offsets != null) {
241 offsets[0] = rawoffset;
242 offsets[1] = dstoffset;
243 }
244 return rawoffset + dstoffset;
|