List of utility methods to do TimeZone Get
Date | getAdjustedDateTime(Date dt, TimeZone tz) Returns a Date object adjusted for the given timezone.
Date result = null; DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); df.setTimeZone(tz); try { result = df.parse(df.format(dt)); } catch (ParseException e) { return result; ... |
String[] | getAllTimezonesSorted() Retrieve all available time zones IDs and sort them. String[] tmz = TimeZone.getAvailableIDs();
Collections.sort(Arrays.asList(tmz));
return tmz;
|
TimeZone | getAsTimeZone(Map params, String propName) get As Time Zone if (params.containsKey(propName)) { Object timezoneObj = params.get(propName); if (timezoneObj instanceof TimeZone) { return (TimeZone) timezoneObj; } else { return TimeZone.getTimeZone(String.valueOf(timezoneObj)); return null; |
String[] | getAvailableTimezones() get Available Timezones if (null == timezones) { DecimalFormat df = new DecimalFormat("'GMT'+00':00';'GMT'-00':00'"); ArrayList<String> tzs = new ArrayList<String>(29); tzs.add("UTC"); tzs.add("GMT"); tzs.add(TimeZone.getDefault().getID()); for (int i = -12; i < 15; i++) { tzs.add(df.format(i)); ... |
Date | getCal(int dayOfMonth, int month, int year, int hours, int minutes, int seconds, String timezone) Get calendar date. Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("GMT" + timezone));
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.HOUR_OF_DAY, hours);
cal.set(Calendar.MINUTE, minutes);
cal.set(Calendar.SECOND, seconds);
...
|
Calendar | getCalendarForTimeZone(final String timeZone) Gets the calendar for time zone. DateTime dateTime = new DateTime(DateTimeZone.forID(timeZone)); Calendar tzCalendar = dateTime.toCalendar(Locale.ENGLISH); return tzCalendar; |
Calendar | getCalendarInstance(TimeZone timeZone, Locale locale) get Calendar Instance return Calendar.getInstance(timeZone, locale);
|
String | getConvertDateString(Date date, TimeZone tz, String fmt) get Convert Date String if (date == null) return null; SimpleDateFormat format = new SimpleDateFormat(fmt); Date newDete = getConvertDate(date, tz); return format.format(newDete); |
Calendar | getCurrentCalendarInTimeZone(final TimeZone timeZone) Get current calendar in time zone return Calendar.getInstance(timeZone);
|
String | getCurrentTimeZone() get Current Time Zone Calendar cal = Calendar.getInstance(); long milliDiff = cal.get(Calendar.ZONE_OFFSET); String[] ids = TimeZone.getAvailableIDs(); String name = null; for (String id : ids) { TimeZone tz = TimeZone.getTimeZone(id); if (tz.getRawOffset() == milliDiff) { name = id; ... |