Java Utililty Methods TimeZone Add

List of utility methods to do TimeZone Add

Description

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

Method

SimpleTimeZoneaddTimeZone(String id, double off)
Add a java.util.SimpleTimeZone
int offset = (new Double(off * 3600000)).intValue();
SimpleTimeZone tz = new SimpleTimeZone(offset, id);
s_timeZoneTable.put(id, tz);
return tz;
longadjustTimeToDefaultTimezone(long time)
Shift the time from UTC to the local timezone
return time + getDefaultTimeZoneOffset();
DatebaseFor(TimeZone tz)
base For
Calendar c = Calendar.getInstance(tz);
c.clear();
c.set(1899, 11, 30, 0, 0, 0);
return c.getTime();
Calendarcal(TimeZone tz)
cal
Calendar cal = (tz != null) ? new GregorianCalendar(tz) : new GregorianCalendar();
cal.clear();
return cal;
booleanisAfter(int month1, int day1, int year1, int hour1, int minute1, int amPm1, int month2, int day2, int year2, int hour2, int minute2, int amPm2, TimeZone timeZone, Locale locale)
is After
Calendar cal1 = new GregorianCalendar(timeZone, locale);
cal1.set(Calendar.MONTH, month1);
cal1.set(Calendar.DATE, day1);
cal1.set(Calendar.YEAR, year1);
cal1.set(Calendar.HOUR, hour1);
cal1.set(Calendar.MINUTE, minute1);
cal1.set(Calendar.AM_PM, amPm1);
Calendar cal2 = new GregorianCalendar(timeZone, locale);
...
booleanisFuture(int month, int year, TimeZone timeZone, Locale locale)
is Future
Calendar curCal = new GregorianCalendar(timeZone, locale);
curCal.set(Calendar.DATE, 1);
Calendar cal = (Calendar) curCal.clone();
cal.set(Calendar.MONTH, month);
cal.set(Calendar.YEAR, year);
return cal.after(curCal);
intmillisFromEpochToHourId(long millis, TimeZone tz)
Convert from millis to hour id
Calendar cal = Calendar.getInstance(tz);
cal.setTimeInMillis(millis);
return calendarToHourId(cal);
CalendarnowWithTimeZone(TimeZone timezone)
now With Time Zone
return Calendar.getInstance(timezone);
longremoveTimeZoneOffset(long t)
remove Time Zone Offset
return t - getTimeZoneOffset(t);
DateshiftDate(Date date, TimeZone timeZone, String pattern)
shift Date
if ((timeZone == null) || (date == null))
    return date;
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
String s = sdf.format(date);
sdf.setTimeZone(timeZone);
try {
    return sdf.parse(s);
} catch (ParseException e) {
...