Java Utililty Methods TimeZone Get

List of utility methods to do TimeZone Get

Description

The list of methods to do TimeZone Get are organized into topic(s).

Method

DategetAdjustedDateTime(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;
TimeZonegetAsTimeZone(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));
...
DategetCal(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);
...
CalendargetCalendarForTimeZone(final String timeZone)
Gets the calendar for time zone.
DateTime dateTime = new DateTime(DateTimeZone.forID(timeZone));
Calendar tzCalendar = dateTime.toCalendar(Locale.ENGLISH);
return tzCalendar;
CalendargetCalendarInstance(TimeZone timeZone, Locale locale)
get Calendar Instance
return Calendar.getInstance(timeZone, locale);
StringgetConvertDateString(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);
CalendargetCurrentCalendarInTimeZone(final TimeZone timeZone)
Get current calendar in time zone
return Calendar.getInstance(timeZone);
StringgetCurrentTimeZone()
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;
...