java.util

Class TimeZone

Implemented Interfaces:
Cloneable, Serializable
Known Direct Subclasses:
SimpleTimeZone

public abstract class TimeZone
extends Object
implements Serializable, Cloneable

TimeZone represents a time zone offset, and also figures out daylight savings.

Typically, you get a TimeZone using getDefault which creates a TimeZone based on the time zone where the program is running. For example, for a program running in Japan, getDefault creates a TimeZone object based on Japanese Standard Time.

You can also get a TimeZone using getTimeZone along with a time zone ID. For instance, the time zone ID for the U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object with:

 TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
 
You can use the getAvailableIDs method to iterate through all the supported time zone IDs. You can then choose a supported ID to get a TimeZone. If the time zone you want is not represented by one of the supported IDs, then a custom time zone ID can be specified to produce a TimeZone. The syntax of a custom time zone ID is:
 CustomID:
         GMT Sign Hours : Minutes
         GMT Sign Hours Minutes
         GMT Sign Hours
 Sign: one of
         + -
 Hours:
         Digit
         Digit Digit
 Minutes:
         Digit Digit
 Digit: one of
         0 1 2 3 4 5 6 7 8 9
 
Hours must be between 0 to 23 and Minutes must be between 00 to 59. For example, "GMT+10" and "GMT+0010" mean ten hours and ten minutes ahead of GMT, respectively.

The format is locale independent and digits must be taken from the Basic Latin block of the Unicode standard. No daylight saving time transition schedule can be specified with a custom time zone ID. If the specified string doesn't match the syntax, "GMT" is used.

When creating a TimeZone, the specified custom time zone ID is normalized in the following syntax:

 NormalizedCustomID:
         GMT Sign TwoDigitHours : Minutes
 Sign: one of
         + -
 TwoDigitHours:
         Digit Digit
 Minutes:
         Digit Digit
 Digit: one of
         0 1 2 3 4 5 6 7 8 9
 
For example, TimeZone.getTimeZone("GMT-8").getID() returns "GMT-08:00".

Three-letter time zone IDs

For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported. However, their use is deprecated because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them.
Since:
JDK1.1
See Also:
Calendar, GregorianCalendar, SimpleTimeZone, Serialized Form

Field Summary

static int
LONG
A style specifier for getDisplayName() indicating a long name, such as "Pacific Standard Time."
static int
SHORT
A style specifier for getDisplayName() indicating a short name, such as "PST."

Constructor Summary

TimeZone()
Sole constructor.

Method Summary

Object
clone()
Creates a copy of this TimeZone.
static String[]
getAvailableIDs()
Gets all the available IDs supported.
static String[]
getAvailableIDs(int rawOffset)
Gets the available IDs according to the given time zone offset.
int
getDSTSavings()
Returns the amount of time to be added to local standard time to get local wall clock time.
static TimeZone
getDefault()
Gets the default TimeZone for this host.
String
getDisplayName()
Returns a name of this time zone suitable for presentation to the user in the default locale.
String
getDisplayName(boolean daylight, int style)
Returns a name of this time zone suitable for presentation to the user in the default locale.
String
getDisplayName(boolean daylight, int style, Locale locale)
Returns a name of this time zone suitable for presentation to the user in the specified locale.
String
getDisplayName(Locale locale)
Returns a name of this time zone suitable for presentation to the user in the specified locale.
String
getID()
Gets the ID of this time zone.
abstract int
getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)
Gets the time zone offset, for current date, modified in case of daylight savings.
int
getOffset(long date)
Returns the offset of this time zone from UTC at the specified date.
abstract int
getRawOffset()
Returns the amount of time in milliseconds to add to UTC to get standard time in this time zone.
static TimeZone
getTimeZone(String ID)
Gets the TimeZone for the given ID.
boolean
hasSameRules(TimeZone other)
Returns true if this zone has the same rule and offset as another zone.
abstract boolean
inDaylightTime(Date date)
Queries if the given date is in daylight savings time in this time zone.
static void
setDefault(TimeZone zone)
Sets the TimeZone that is returned by the getDefault method.
void
setID(String ID)
Sets the time zone ID.
abstract void
setRawOffset(int offsetMillis)
Sets the base time zone offset to GMT.
abstract boolean
useDaylightTime()
Queries if this time zone uses daylight savings time.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

LONG

public static final int LONG
A style specifier for getDisplayName() indicating a long name, such as "Pacific Standard Time."
Field Value:
1
Since:
1.2
See Also:
SHORT
Usages and Demos :

View More Examples of TimeZone.LONG
   1:                 boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0;
   2:                 String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT);
   3:                 buffer.append (zoneID);
   4:                 break;
   5:               default:

View Full Code Here

SHORT

public static final int SHORT
A style specifier for getDisplayName() indicating a short name, such as "PST."
Field Value:
0
Since:
1.2
See Also:
LONG
Usages and Demos :

View More Examples of TimeZone.SHORT
   1:     
   2:     String name = tz.getDisplayName(isDST, TimeZone.SHORT);
   3:     Value nameV = StringValue.create(name.toLowerCase());
   4:     
   5:     Value zones = array.get(nameV);

View Full Code Here
   1:         TimeZone tz = m_calendar.getTimeZone();
   2:         lTZ.setText(tz.getDisplayName(tz.inDaylightTime(m_calendar.getTime()), TimeZone.SHORT));
   3: 
   4:         m_calendar.set(m_currentYear, m_currentMonth-1, m_currentDay, m_current24Hour, m_currentMinute, 0);
   5:         m_calendar.set(java.util.Calendar.MILLISECOND, 0);

View Full Code Here
   1:                 boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0;
   2:                 String zoneID = zone.getDisplayName (isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT);
   3:                 buffer.append (zoneID);
   4:                 break;
   5:               default:

View Full Code Here
   1:   private static String _localDstName =
   2:     _localTimeZone.getDisplayName(true, TimeZone.SHORT);
   3:   private static String _localStdName =
   4:         ...
   5:     _localTimeZone.getDisplayName(false, TimeZone.SHORT);
   6: 
   7:         ...
   8:   private static String _gmtDstName =
   9:     _gmtTimeZone.getDisplayName(true, TimeZone.SHORT);
  10:   private static String _gmtStdName =

View Full Code Here
   1:                  {
   2:                     zone = TimeZone.getDefault().getDisplayName(false,TimeZone.SHORT);
   3:                  }
   4:         ...
   5:               {
   6:                  return formatter.parse(dateString + " " +stdZone.getDisplayName(true,TimeZone.SHORT));
   7:               }
   8:               return date;
   9:            }

View Full Code Here

Constructor Details

TimeZone

public TimeZone()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Details

clone

public Object clone()
Creates a copy of this TimeZone.
Overrides:
clone in interface Object
Returns:
a clone of this TimeZone
Usages and Demos :

View More Examples of clone()
   1: import java.util.Date;
   2: import java.util.TimeZone;
   3: import java.text.DateFormat;
   4:         ...
   5: 
   6:     private TimeZone timezone;
   7: 
   8:         ...
   9:         ensureTimeUnit(unit);
  10:         this.timezone = (TimeZone) timezone.clone();
  11:     }
  12:         ...
  13:     public void setTimeZone(final TimeZone timezone) {
  14:         this.timezone = (TimeZone) timezone.clone();

View Full Code Here

getAvailableIDs

public static String[] getAvailableIDs()
Gets all the available IDs supported.
Returns:
an array of IDs.
Usages and Demos :

View More Examples of getAvailableIDs()
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:     
   6:     return TimeZone.getAvailableIDs();
   7:     
   8:     }

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:         public String[] getOptions() {
   6:             return TimeZone.getAvailableIDs();
   7:         }
   8:         
   9:         public String getSelected() {

View Full Code Here
   1:     String[] timeZones;
   2:     timeZones = TimeZone.getAvailableIDs();
   3:     for (int i = 0; i < timeZones.length; i++) {
   4:         ...
   5:       TimeZone tz = TimeZone.getTimeZone(timeZones[i]);
   6:       int rawOffset = tz.getRawOffset();
   7:         ...
   8:       String gmtString = "(GMT" + (gmtInt < 0 ? "-" : "+") + (Math.abs(gmtInt) > 9 ? "" : "0") + Math.abs(gmtInt) + ":" + (fraction != 0 ? "" + fraction : "00") + ") ";
   9:       String timeZone = gmtString + tz.getDisplayName();
  10:       if (!tz.getDisplayName().startsWith("GMT")) {

View Full Code Here
   1: import java.util.Arrays;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:   public static String[] fuseauxHorairesDisponibles() {
   6:     return TimeZone.getAvailableIDs();
   7:   }
   8:   public static void classe(ICreneau[] _creneaux) {
   9:     if ((_creneaux == null) || (_creneaux.length == 0)) {

View Full Code Here

getAvailableIDs

public static String[] getAvailableIDs(int rawOffset)
Gets the available IDs according to the given time zone offset.
Parameters:
rawOffset - the given time zone GMT offset.
Returns:
an array of IDs, where the time zone for that ID has the specified GMT offset. For example, "America/Phoenix" and "America/Denver" both have GMT-07:00, but differ in daylight savings behavior.
Usages and Demos :

View More Examples of getAvailableIDs(int rawOffset)
   1:     if (useGMT) {
   2:         calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
   3:     }
   4:         ...
   5:     if (useGMT) {
   6:         calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
   7:     }
   8:         ...
   9:         withoutDots.equalsIgnoreCase(zones[ix][4])) {
  10:          TimeZone zone = TimeZone.getTimeZone(zones[ix][0]);
  11:         return new ClockToken(ClockToken.ZONE, zone);
  12:         ...
  13: ) {
  14:     String tzNames[] = TimeZone.getAvailableIDs(rawOffset*MILLIS_PER_HOUR);

View Full Code Here

getDSTSavings

public int getDSTSavings()
Returns the amount of time to be added to local standard time to get local wall clock time.

The default implementation always returns 3600000 milliseconds (i.e., one hour) if this time zone observes Daylight Saving Time. Otherwise, 0 (zero) is returned.

If an underlying TimeZone implementation subclass supports historical Daylight Saving Time changes, this method returns the known latest daylight saving value.

Returns:
the amount of saving time in milliseconds
Since:
1.4
Usages and Demos :

View More Examples of getDSTSavings()
   1: import java.util.Date;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:         {
   6:             TimeZone tz = TimeZone.getDefault();
   7:             int rawOffset = tz.getRawOffset();
   8:         ...
   9:             if (inDaylightTime)
  10:                 rawOffset += tz.getDSTSavings();
  11:             return LispThread.currentThread().setValues(

View Full Code Here

getDefault

public static TimeZone getDefault()
Gets the default TimeZone for this host. The source of the default TimeZone may vary with implementation.
Returns:
a default TimeZone.
Usages and Demos :

View More Examples of getDefault()
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:         InheritableThreadLocal _thdTZone = new InheritableThreadLocal();
   6:     public static final TimeZone getCurrent() {
   7:         ...
   8:         final TimeZone l = (TimeZone)_thdTZone.get();
   9:         ...
  10:         return l != null ? l: TimeZone.getDefault();

View Full Code Here
   1: import java.util.Locale;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:                         DateHelper.parseDateTime("11-jul-03 12:27"), 
   6:                         TimeZone.getDefault()).getTime());
   7:     }
   8:         ...
   9:                         DateHelper.parseDateTime("11-feb-04 12:27"), 
  10:                         TimeZone.getDefault()).getTime());
  11:     }
  12:         ...
  13:                         DateHelper.parseDateTime("11-jul-03 12:27"), 15, 
  14:                         TimeZone.getDefault()).getTime());

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:   public static long getTimeZoneOffset(TimeZone tz) {
   7:     if (tz == null) {
   8:         ...
   9:       return TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000;
  10:     } else {
  11:         ...
  12: 
  13:   public static String getDateInSec(long time, TimeZone tz) {

View Full Code Here
   1: import java.util.Locale;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:   private TimeZone _timeZone = null;
   7:   private Locale _locale = null;
   8:         ...
   9: 
  10:   public DateFormatManager(TimeZone timeZone) {
  11:     super();
  12:         ...
  13:     if (_timeZone == null) {
  14:       return TimeZone.getDefault();

View Full Code Here
   1: import java.util.ResourceBundle;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:     private void layoutTimeZonePanel(ResourceBundle res, Border border) {
   6:         String title = res.getString("Label.TimeZone");
   7:         layoutDropDownPanel(m_timeZoneSelector.getUi(), title, border);
   8:         ...
   9:         
  10:         TimeZone tz = TIMEZONE_SUPPORT ? m_timeZoneSelector.getSelectedTimeZone() : 
  11:         ...
  12:             TimeZone.getDefault();

View Full Code Here

getDisplayName

public final String getDisplayName()
Returns a name of this time zone suitable for presentation to the user in the default locale. This method returns the long name, not including daylight savings. If the display name is not available for the locale, then this method returns a string in the normalized custom ID format.
Returns:
the human-readable name of this time zone in the default locale.
Since:
1.2
Usages and Demos :

View More Examples of getDisplayName()
   1: import java.util.Date;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:     }
   6:     else if (value instanceof TimeZone)
   7:     {
   8:         ...
   9:       TimeZone timeZone = (TimeZone) value;
  10:         ...
  11:       JLabel label = new JLabel(timeZone.getDisplayName());

View Full Code Here
   1:       if (locales[i].getCountry().length() > 0) {
   2:         this.addItem(i, locales[i].getDisplayName());
   3:       }
   4:         ...
   5:     String[] timeZones;
   6:     timeZones = TimeZone.getAvailableIDs();
   7:     for (int i = 0; i < timeZones.length; i++) {
   8:         ...
   9:       TimeZone tz = TimeZone.getTimeZone(timeZones[i]);
  10:       int rawOffset = tz.getRawOffset();
  11:         ...
  12:       String gmtString = "(GMT" + (gmtInt < 0 ? "-" : "+") + (Math.abs(gmtInt) > 9 ? "" : "0") + Math.abs(gmtInt) + ":" + (fraction != 0 ? "" + fraction : "00") + ") ";
  13:       String timeZone = gmtString + tz.getDisplayName();

View Full Code Here

getDisplayName

public final String getDisplayName(boolean daylight,
                                   int style)
Returns a name of this time zone suitable for presentation to the user in the default locale. If the display name is not available for the locale, then this method returns a string in the normalized custom ID format.
Parameters:
daylight - if true, return the daylight savings name.
style - either LONG or SHORT
Returns:
the human-readable name of this time zone in the default locale.
Since:
1.2
Usages and Demos :

View More Examples of getDisplayName(boolean daylight,int style)
   1: import jp.ujihara.java.util.SimpleTimeZone;
   2: import jp.ujihara.java.util.TimeZone;
   3: 
   4:         ...
   5:                 buffer.setDefaultAttribute (DateFormat.Field.TIME_ZONE);
   6:                 TimeZone zone = calendar.getTimeZone();
   7:                 boolean isDST = calendar.get (Calendar.DST_OFFSET) != 0;
   8:         ...
   9:                 String zoneID = zone.getDisplayName(isDST, p.size > 3 ? TimeZone.LONG : TimeZone.SHORT);
  10:                 buffer.append (zoneID);
  11:         ...
  12:                     saw_timezone = true;
  13:                     TimeZone tz = TimeZone.getTimeZone (strings[0]);

View Full Code Here
   1: import java.util.GregorianCalendar;
   2: import java.util.TimeZone;
   3: import java.util.logging.Level;
   4:         ...
   5: 
   6:   private static TimeZone _localTimeZone = TimeZone.getDefault();
   7:   private static TimeZone _gmtTimeZone = TimeZone.getTimeZone("GMT");
   8:         ...
   9:   private static String _localDstName =
  10:     _localTimeZone.getDisplayName(true, TimeZone.SHORT);
  11:   private static String _localStdName =
  12:         ...
  13:     _localTimeZone.getDisplayName(false, TimeZone.SHORT);

View Full Code Here

getDisplayName

public String getDisplayName(boolean daylight,
                             int style,
                             Locale locale)
Returns a name of this time zone suitable for presentation to the user in the specified locale. If the display name is not available for the locale, then this method returns a string in the normalized custom ID format.
Parameters:
daylight - if true, return the daylight savings name.
style - either LONG or SHORT
locale - the locale in which to supply the display name.
Returns:
the human-readable name of this time zone in the given locale or in the default locale if the given locale is not recognized.
Throws:
IllegalArgumentException - style is invalid.
Since:
1.2

getDisplayName

public final String getDisplayName(Locale locale)
Returns a name of this time zone suitable for presentation to the user in the specified locale. This method returns the long name, not including daylight savings. If the display name is not available for the locale, then this method returns a string in the normalized custom ID format.
Parameters:
locale - the locale in which to supply the display name.
Returns:
the human-readable name of this time zone in the given locale or in the default locale if the given locale is not recognized.
Since:
1.2
Usages and Demos :

View More Examples of getDisplayName(Locale locale)
   1:         cbPM.setSelected(pm);
   2:         TimeZone tz = m_calendar.getTimeZone();
   3:         ...
   4:         lTZ.setText(tz.getDisplayName(tz.inDaylightTime(m_calendar.getTime()), TimeZone.SHORT));
   5: 
   6:         m_calendar.set(m_currentYear, m_currentMonth-1, m_currentDay, m_current24Hour, m_currentMinute, 0);
   7:         m_calendar.set(java.util.Calendar.MILLISECOND, 0);

View Full Code Here

getID

public String getID()
Gets the ID of this time zone.
Returns:
the ID of this time zone.
Usages and Demos :

View More Examples of getID()
   1: package org.roller.util;
   2: import java.util.TimeZone;
   3: import java.util.Comparator;
   4:         ...
   5:     {
   6:         if (obj1 instanceof TimeZone && obj2 instanceof TimeZone)
   7:         {
   8:         ...
   9:             {
  10:                 return zone1.getID().compareTo(zone2.getID());
  11:             }

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: import java.beans.PropertyEditorSupport;
   4:         ...
   5:         try {
   6:             setValue(TimeZone.getTimeZone(text));
   7:         } catch (IllegalArgumentException e) {
   8:         ...
   9:     public String getAsText() {
  10:         TimeZone tz = (TimeZone)getValue();
  11:         if(tz == null) {
  12:         ...
  13:         else {
  14:             return tz.getID();

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:   {
   6:     TimeZone tz = (TimeZone) o;
   7:         ...
   8:     return tz.getID();
   9:   }

View Full Code Here
   1:    private static String fixDate(String s,
   2:                                  TimeZone tz)
   3:    {
   4:         ...
   5:       String tzID = tz.getID();
   6:       switch (s.length()) {
   7:         ...
   8:          cal.set(year, month - 1, day, hour, minute, second);
   9:          cal.setTimeZone(TimeZone.getTimeZone(tzID));
  10:       } catch (Exception ex) {

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: {
   6:   private TimeZone _timeZone;
   7:   
   8:         ...
   9:   {
  10:     _timeZone = TimeZone.getDefault();
  11:   }
  12:         ...
  13:     zone.put("offset", offset);
  14:     zone.put("timezone_id", tz.getID());

View Full Code Here

getOffset

public abstract int getOffset(int era,
                              int year,
                              int month,
                              int day,
                              int dayOfWeek,
                              int milliseconds)
Gets the time zone offset, for current date, modified in case of daylight savings. This is the offset to add to UTC to get local time.

This method returns a historically correct offset if an underlying TimeZone implementation subclass supports historical Daylight Saving Time schedule and GMT offset changes.

Parameters:
era - the era of the given date.
year - the year in the given date.
month - the month in the given date. Month is 0-based. e.g., 0 for January.
day - the day-in-month of the given date.
dayOfWeek - the day-of-week of the given date.
milliseconds - the milliseconds in day in standard local time.
Returns:
the offset in milliseconds to add to GMT to get local time.

getOffset

public int getOffset(long date)
Returns the offset of this time zone from UTC at the specified date. If Daylight Saving Time is in effect at the specified date, the offset value is adjusted with the amount of daylight saving.

This method returns a historically correct offset value if an underlying TimeZone implementation subclass supports historical Daylight Saving Time schedule and GMT offset changes.

Parameters:
date - the date represented in milliseconds since January 1, 1970 00:00:00 GMT
Returns:
the amount of time in milliseconds to add to UTC to get local time.
Since:
1.4
Usages and Demos :

View More Examples of getOffset(long date)
   1: import java.util.ArrayList;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:   public static long getTimeZoneOffset(TimeZone tz) {
   7:     if (tz == null) {
   8:         ...
   9:       return TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000;
  10:     } else {
  11:         ...
  12:       return tz.getOffset(System.currentTimeMillis()) / 1000;

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: {
   6:   private TimeZone _timeZone;
   7:   
   8:         ...
   9:   {
  10:     _timeZone = TimeZone.getDefault();
  11:   }
  12:         ...
  13:   {
  14:     return _timeZone.getOffset(dateTime.getTime()) / 1000L;

View Full Code Here
   1: import java.util.Date;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:         {
   6:             TimeZone tz = TimeZone.getDefault();
   7:             int rawOffset = tz.getRawOffset();
   8:             final boolean inDaylightTime =
   9:                 tz.inDaylightTime(new Date(System.currentTimeMillis()));

View Full Code Here
   1: import java.util.GregorianCalendar;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:     private String timeZone = "EST" ;
   7:     private String dateFormat = "MMM d, yyyy hh:mm:ss a" ;
   8:         ...
   9:   {
  10:     TimeZone tz = TimeZone.getTimeZone(timezoneid);
  11:     long ls = ds.getTime();
  12:         ...
  13:     int startoffset = tz.getOffset(ls);

View Full Code Here
   1: import java.util.GregorianCalendar;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:         TimeZone tz = TimeZone.getTimeZone(tzID);
   7:         if (!tz.getID().equals(tzID)) {
   8:         ...
   9:         TimeZone tz = cal.getTimeZone();
  10:         int offset = tz.getOffset(cal.getTimeInMillis());
  11:         if (offset != 0) {

View Full Code Here

getRawOffset

public abstract int getRawOffset()
Returns the amount of time in milliseconds to add to UTC to get standard time in this time zone. Because this value is not affected by daylight saving time, it is called raw offset.

If an underlying TimeZone implementation subclass supports historical GMT offset changes, the method returns the raw offset value of the current date. In Honolulu, for example, its raw offset changed from GMT-10:30 to GMT-10:00 in 1947, and this method always returns -36000000 milliseconds (i.e., -10 hours).

Returns:
the amount of raw offset time in milliseconds to add to UTC.
Usages and Demos :

View More Examples of getRawOffset()
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:     public static void main(String[] args) {
   6:         TimeZone defaultTZ = TimeZone.getDefault();
   7:         String[] ids = TimeZone.getAvailableIDs();
   8:         ...
   9:         System.out.println("\nDefault timezone is " + defaultTZ.getID() + 
  10:                         ", GMT offset = " + defaultTZ.getRawOffset());
  11:     }

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: import java.util.SimpleTimeZone;
   4:         ...
   5: 
   6:     String[] tzid = TimeZone.getAvailableIDs();
   7: 
   8:         ...
   9:     for(int i = 0; i < tzid.length; i++) {
  10:     TimeZone tz = TimeZone.getTimeZone(tzid[i]);
  11:         ...
  12:     int offset  = tz.getRawOffset();

View Full Code Here
   1: import java.util.Date;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:         {
   6:             TimeZone tz = TimeZone.getDefault();
   7:         ...
   8:             int rawOffset = tz.getRawOffset();
   9:             final boolean inDaylightTime =

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: import javax.xml.XMLConstants;
   4:         ...
   5:           {
   6:             String timezone = value.substring(len - start);
   7:         ...
   8:             int i = timezone.indexOf(':');
   9:             if (i == -1)
  10:         ...
  11:                   return null;
  12:                 time.minutes += tz.getRawOffset();

View Full Code Here
   1: import java.util.List;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:     private int timeZone = (int) (TimeZone.getDefault().getRawOffset()/1000/60);
   7: 
   8:         ...
   9:             availableTimeZones = new ArrayList();
  10:             String[] ids = TimeZone.getAvailableIDs() ;
  11:             DecimalFormat formatter = new DecimalFormat("00");
  12:         ...
  13:             for (int i = 0; i < ids.length; i++) {
  14:                 TimeZone tz = TimeZone.getTimeZone(ids[i]);

View Full Code Here

getTimeZone

public static TimeZone getTimeZone(String ID)
Gets the TimeZone for the given ID.
Parameters:
ID - the ID for a TimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00". Note that the support of abbreviations is for JDK 1.1.x compatibility only and full names should be used.
Returns:
the specified TimeZone, or the GMT zone if the given ID cannot be understood.
Usages and Demos :

View More Examples of getTimeZone(String ID)
   1: import java.text.ParseException;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:                                             cronExpression,
   6:                                             TimeZone.getTimeZone("Europe/Paris"));
   7:                                             
   8:                                             
   9:                 sched.scheduleJob(jobDetail, trigger);

View Full Code Here
   1: import java.util.Locale;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:     
   6:     static private TimeZone getTimeZone(String dateFromServer) {
   7:         String tz = null;
   8:             resultTz.append('+');
   9:         }

View Full Code Here
   1: 
   2:     public ProjectVOX(String TimeZone, ActionForm form)
   3:     {
   4:         ...
   5:                     new java.sql.Date(startyear,startmonth,startday),
   6:                     java.util.TimeZone.getTimeZone(TimeZone),
   7:         ...
   8:                     java.util.TimeZone.getTimeZone("EST")                    
   9:                 )                
  10:         ...
  11:                     new java.sql.Date(endyear,endmonth,endday),
  12:                     java.util.TimeZone.getTimeZone(TimeZone),

View Full Code Here
   1: 
   2:     public TaskVOX(String TimeZone, ActionForm form)
   3:     {
   4:         ...
   5:                 ),
   6:                 java.util.TimeZone.getTimeZone(TimeZone),
   7:         ...
   8:                 java.util.TimeZone.getTimeZone("EST")
   9:             )
  10:         ...
  11:                     ),
  12:                     java.util.TimeZone.getTimeZone(TimeZone),

View Full Code Here
   1: import java.io.ObjectOutputStream;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:         QuarterDateFormat qf1 = new QuarterDateFormat(
   6:             TimeZone.getTimeZone("GMT"), new String[] {"1", "2", "3", "4"}
   7:         );
   8:         ...
   9:         QuarterDateFormat qf2 = new QuarterDateFormat(
  10:             TimeZone.getTimeZone("GMT"), new String[] {"1", "2", "3", "4"}
  11:         );
  12:         ...
  13:         qf1 = new QuarterDateFormat(
  14:             TimeZone.getTimeZone("PST"), new String[] {"1", "2", "3", "4"}

View Full Code Here

hasSameRules

public boolean hasSameRules(TimeZone other)
Returns true if this zone has the same rule and offset as another zone. That is, if this zone differs only in ID, if at all. Returns false if the other zone is null.
Parameters:
other - the TimeZone object to be compared with
Returns:
true if the other zone is not null and is the same as this one, with the possible exception of the ID
Since:
1.2

inDaylightTime

public abstract boolean inDaylightTime(Date date)
Queries if the given date is in daylight savings time in this time zone.
Parameters:
date - the given Date.
Returns:
true if the given date is in daylight savings time, false, otherwise.
Usages and Demos :

View More Examples of inDaylightTime(Date date)
   1:         cbPM.setSelected(pm);
   2:         TimeZone tz = m_calendar.getTimeZone();
   3:         ...
   4:         lTZ.setText(tz.getDisplayName(tz.inDaylightTime(m_calendar.getTime()), TimeZone.SHORT));
   5: 
   6:         m_calendar.set(m_currentYear, m_currentMonth-1, m_currentDay, m_current24Hour, m_currentMinute, 0);
   7:         m_calendar.set(java.util.Calendar.MILLISECOND, 0);

View Full Code Here

setDefault

public static void setDefault(TimeZone zone)
Sets the TimeZone that is returned by the getDefault method. If zone is null, reset the default to the value it had originally when the VM first started.
Parameters:
zone - the new default time zone
See Also:
getDefault()
Usages and Demos :

View More Examples of setDefault(TimeZone zone)
   1: 
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:     private static final TimeZone originalTimeZone = TimeZone.getDefault();
   7: 
   8:         ...
   9:     public static void change(String timeZone) {
  10:         TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
  11:     }
  12:         ...
  13:     public static void reset() {
  14:         TimeZone.setDefault(originalTimeZone);

View Full Code Here
   1: import java.util.Date;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:     public void testLocalDate() throws ParseException {
   6:         TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
   7:         
   8:         ...
   9:     public void testTimeZoneDate() throws ParseException {
  10:         TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
  11:         

View Full Code Here
   1: 
   2: import java.util.TimeZone;
   3: import java.util.SimpleTimeZone;
   4:         ...
   5: 
   6:     String[] tzid = TimeZone.getAvailableIDs();
   7: 
   8:         ...
   9:     for(int i = 0; i < tzid.length; i++) {
  10:     TimeZone tz = TimeZone.getTimeZone(tzid[i]);
  11:     int offset  = tz.getRawOffset();
  12:         ...
  13: 
  14:     TimeZone.setDefault(tz);

View Full Code Here
   1: import java.io.InputStream;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5:     protected int count = 0;
   6:     private TimeZone tz;
   7:     
   8:         ...
   9:     
  10:     public ScheduleTester(String configFile, TimeZone timeZone) 
  11:     throws Exception {
  12:         ...
  13:     public void run(TestResult result) {
  14:         TimeZone.setDefault(tz);

View Full Code Here
   1: import java.util.Date;
   2: import java.util.TimeZone;
   3: 
   4:         ...
   5: 
   6:         TimeZone.setDefault(null);
   7:         ...
   8:         logger.debug(TimeZone.getDefault());
   9:         
  10:         ...
  11:             
  12:         TimeZone.setDefault(TimeZone.getTimeZone("Australia/Sydney"));

View Full Code Here

setID

public void setID(String ID)
Sets the time zone ID. This does not change any other data in the time zone object.
Parameters:
ID - the new time zone ID.

setRawOffset

public abstract void setRawOffset(int offsetMillis)
Sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.

If an underlying TimeZone implementation subclass supports historical GMT offset changes, the specified GMT offset is set as the latest GMT offset and the difference from the known latest GMT offset value is used to adjust all historical GMT offset values.

Parameters:
offsetMillis - the given base time zone offset to GMT.
Usages and Demos :

View More Examples of setRawOffset(int offsetMillis)
   1: import java.util.ArrayList;
   2: import java.util.TimeZone;
   3: import java.util.Calendar;
   4:         ...
   5:            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   6:            int offset = TimeZone.getTimeZone(getTimeZone()).getRawOffset();
   7:         ...
   8:            TimeZone zone = TimeZone.getTimeZone("GMT");
   9:         ...
  10:            zone.setRawOffset(offset);

View Full Code Here
   1: import java.util.GregorianCalendar;
   2: import java.util.TimeZone;
   3: import java.util.Vector;
   4:         ...
   5:     
   6:     private static int TIMEZONE_OFFSET = TimeZone.getDefault().getRawOffset();
   7: 
   8:         ...
   9:         int i   = 0;
  10:         boolean timezone    = false;
  11:         for ( ; i < chars.length; i++) {
  12:         ...
  13:                 if (designator == '-') millis = 0 - millis;
  14:                 tz.setRawOffset(millis);

View Full Code Here

useDaylightTime

public abstract boolean useDaylightTime()
Queries if this time zone uses daylight savings time.

If an underlying TimeZone implementation subclass supports historical Daylight Saving Time schedule changes, the method refers to the latest Daylight Saving Time schedule information.

Returns:
true if this time zone uses daylight savings time, false, otherwise.