This is what I did:
// get the local time
Date _date = new Date();
long currentTime = _date.getTime();
// now we get the local time zone and date info
// the date info is passed into TimeZone.getOffset
// which gives us the GMT Offset, but also factor in
// Daylight Saving Time
TimeZone _timeZone = TimeZone.getDefault();
Calendar _calendar = Calendar.getInstance();
int gmtOffset = _timeZone.getOffset(1, _calendar.get(Calendar.YEAR), _calendar.get(Calendar.MONTH), _calendar.get(Calendar.DATE), _calendar.get(Calendar.DAY_OF_WEEK), _calendar.get(Calendar.MILLISECOND));
// now that we have our time
// and the GMT offset with DST considered
// we can display it (in long notation)
System.out.println("GMT Time as Long: " + currentTime - gmtOffset);
|