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

java.util.CalendargetTimeInCurrentDay(long now, TimeZone tz, int hour, int minute, int second, int millisecond)
get Time In Current Day
java.util.Calendar cal = java.util.Calendar.getInstance(tz);
cal.setTimeInMillis(now);
cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
cal.set(java.util.Calendar.MINUTE, minute);
cal.set(java.util.Calendar.SECOND, second);
cal.set(java.util.Calendar.MILLISECOND, millisecond);
return cal;
longgetTimeTry(boolean lenient, TimeZone tz, int year, int month, int day, int hour, int minute, int second, int millis)
get Time Try
Calendar c;
if (tz == null) {
    c = getCalendar();
} else {
    c = Calendar.getInstance(tz);
synchronized (c) {
    c.clear();
...
CalendargetTimeWithTimeZone(final String timezoneId)
get Time With Time Zone
final TimeZone timeZone = TimeZone.getTimeZone(timezoneId);
final Calendar timeWithZone = Calendar.getInstance(timeZone);
return timeWithZone;
TimeZonegetTimeZone(Calendar cal)
Gets the active time zone based on a Calendar argument
if (cal == null) {
    return defaultZone;
return cal.getTimeZone();
TimeZonegetTimeZone(final String ID)
get Time Zone
return TimeZone.getTimeZone(ID);
TimeZonegetTimeZoneByOffSet(String offSetInString)
get Time Zone By Off Set
String timeZoneID = "";
Short offSetInShort = Short.parseShort(offSetInString);
if (offSetInShort > 0) {
    timeZoneID = "GMT+" + offSetInShort;
} else {
    timeZoneID = "GMT" + offSetInShort;
return TimeZone.getTimeZone(timeZoneID);
...
intgetTimezoneDifference(String timezone1, String timezone2)
get Timezone Difference
Calendar lCalendar = new GregorianCalendar(TimeZone.getTimeZone(timezone1));
lCalendar.setTimeInMillis(new Date().getTime());
int Timezone1HourOfDay = lCalendar.get(Calendar.HOUR_OF_DAY);
int Timezone1DayOfMonth = lCalendar.get(Calendar.DAY_OF_MONTH);
lCalendar = new GregorianCalendar(TimeZone.getTimeZone(timezone2));
lCalendar.setTimeInMillis(new Date().getTime());
int TimezoneHourOfDay = lCalendar.get(Calendar.HOUR_OF_DAY);
int TimezoneDayOfMonth = lCalendar.get(Calendar.DAY_OF_MONTH);
...
StringgetTimeZoneID()
get Time Zone ID
return TimeZone.getDefault().getID();
MapgetTimeZoneIDs()
get Time Zone I Ds
return __timeZoneIDs;
StringgetTimeZoneOffset()
get Time Zone Offset
Calendar cal = Calendar.getInstance();
TimeZone currentTimeZone = cal.getTimeZone();
Calendar currentDt = new GregorianCalendar(currentTimeZone, Locale.US);
int gmtOffset = currentTimeZone.getOffset(currentDt.get(0), currentDt.get(1), currentDt.get(2),
        currentDt.get(5), currentDt.get(7), currentDt.get(14));
int hour = gmtOffset / 3600000;
int min = Math.abs((gmtOffset - hour * 3600000) / 60000);
return "" + hour + ":" + min;
...