List of utility methods to do TimeZone Create
Date | getUserTimeZoneDate(String userTimezone) get User Time Zone Date Date date = new Date(); System.out.println(date); SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); sdf.setTimeZone(TimeZone.getTimeZone(userTimezone)); String datestr = sdf.format(date); System.out.println(datestr); String[] datearr = datestr.split(" "); String newstr = datestr.replace(datearr[4], " "); ... |
void | testSimpleTimeZone() test Simple Time Zone SimpleTimeZone zone = new SimpleTimeZone(-28800000, "America/Los_Angeles"); System.out.println(zone); |
TimeZone | toTimeZone(int gmtOffset) Returns a TimeZone object based upon an hour offset from GMT. if (gmtOffset > 12 || gmtOffset < -14) { throw new IllegalArgumentException("Invalid GMT offset"); String tzId = gmtOffset > 0 ? "Etc/GMT+" : "Etc/GMT"; return TimeZone.getTimeZone(tzId + gmtOffset); |
TimeZone | toTimeZone(String value) to Time Zone TimeZone result = null; if (value != null) { result = TimeZone.getTimeZone(value); return result; |
TimeZone | toTimeZone(String zone) Lookup timezone by ID. if (zone == null) { return null; return TimeZone.getTimeZone(zone); |