Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.cldc.util.j2me
Class TimeZoneImpl

    java.lang.Object
      java.util.TimeZone
          com.sun.cldc.util.TimeZoneImplementation
              com.sun.cldc.util.j2me.TimeZoneImpl

    public class TimeZoneImpl

extends TimeZoneImplementation

This class provides the time zone implementations for J2ME CLDC/MIDP. By default, the only supported time zone is UTC/GMT. Vendor-specific implementations may provide additional time zones.

For Sun SPOTs the following additional time zones are supported:

         HST, AST, PST, MST, CST & EST and "GMT+hh:mm"

plus we allow other timezones to be user defined via system properties passed in to Squawk on the command line.

The default time zone is "PST". It can be changed to another supported time zone by setting the system property `com.sun.cldc.util.j2me.TimeZoneImpl.timezone` E.g. to make the default be "EST" include the following in the command line to start Squawk:

        -Dcom.sun.cldc.util.j2me.TimeZoneImpl.timezone=EST

To add additional time zones use the system property `com.sun.cldc.util.j2me.TimeZoneImpl.additionaltimezones`, where its value is a list of the time zones to add in the format:

         tzname1={+-}hh{:mm}{,daylight_savings_spec};tzname2=...;

where

         daylight_savings_spec =
               start_month,start_day,start_day_of_week,start_time,
               end_month,end_day,end_day_of_week,end_time,hh{:mm}

To specify the last Sunday of the month set the day_of_week to Calendar.SUNDAY and the day to -1, i.e. day is interpreted then to be which Sunday (1 = first, 2 = second, -2 = second last, etc.).

It is also possible to specify a date such as the first Sunday before/after a given day of the month by setting the day_of_week to be negative. If the day value is negative then the day_of_week before that day is specified.

For example an Australian might define:

        -Dcom.sun.cldc.util.j2me.TimeZoneImpl.additionaltimezones=
              Australia/Perth=8;Australia/Darwin=9:30;Australia/Adelaide=9:30,9,-1,1,2,2,-1,1,2,1;
              Australia/Brisbane=10;Australia/Sydney=10,9,-1,1,2,2,-1,1,3,1;
              Australia/Lord_Howe=10:30,9,-1,1,2,2,-1,1,3,0:30;

Refer to the time zone defining code at the end of this file for examples of the values to use, e.g.:

        new TimeZoneImpl((int)(9.5*ONE_HOUR), "Australia/Adelaide",
                    Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*ONE_HOUR,
                    Calendar.MARCH, -1, Calendar.SUNDAY, 3*ONE_HOUR, 1*ONE_HOUR),
        // Rule AS  1987    max -   Oct lastSun 2:00s   1:00    -
        // Rule AS  1995    max -   Mar lastSun 2:00s   0   -
        // Australia/Adelaide   South Australia(AU) 9:30    AS  CST

See Also:
  `TimeZone`

Field Summary
`static String` | `HOME_ID`

Constructor Summary
`TimeZoneImpl()`

Method Summary
`boolean` | `equals(Object object)` Indicates whether some other object is "equal to" this one.
`String` | `getID()` Gets the ID of this time zone.
`String[]` | `getIDs()` Gets all the available IDs supported.
`TimeZone` | `getInstance(String ID)` Gets the `TimeZone` for the given ID.
`int` | `getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)` Gets the time zone offset, for the specified date, modified in case of daylight savings.
`int` | `getRawOffset()` Gets the GMT offset for this time zone.
`int` | `hashCode()` Returns a hash code value for the object.
`boolean` | `useDaylightTime()` Queries if this time zone uses Daylight Savings Time.

Methods inherited from class java.util.TimeZone
`getAvailableIDs, getDefault, getTimeZone`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### HOME_ID

    public static String HOME_ID

Constructor Detail

### TimeZoneImpl

    public TimeZoneImpl()

Method Detail

### getOffset

    public int getOffset(int era,
                         int year,
                         int month,
                         int day,
                         int dayOfWeek,
                         int millis)

  Gets the time zone offset, for the specified date, modified in case of daylight savings. This is the offset to add *to* GMT to get local time. This method may return incorrect results for rules that start at the end of February (e.g., last Sunday in February) or the beginning of March (e.g., March 1).

  Specified by:
    `getOffset` in class `TimeZone`
  Parameters:
    `era` - The era of the given date (0 = BC, 1 = AD).
    `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.
    `millis` - The milliseconds in day in standard local time.
  Returns:
    The offset to add *to* GMT to get local time.
  Throws:
    `IllegalArgumentException` - the era, month, day, dayOfWeek, or millis parameters are out of range

### getRawOffset

    public int getRawOffset()

  Gets the GMT offset for this time zone.

  Specified by:
    `getRawOffset` in class `TimeZone`
  Returns:
    the GMT offset for this time zone.

### useDaylightTime

    public boolean useDaylightTime()

  Queries if this time zone uses Daylight Savings Time.

  Specified by:
    `useDaylightTime` in class `TimeZone`
  Returns:
    if this time zone uses Daylight Savings Time.

### getID

    public String getID()

  Gets the ID of this time zone.

  Overrides:
    `getID` in class `TimeZone`
  Returns:
    the ID of this time zone.

### getInstance

    public TimeZone getInstance(String ID)

  Gets the `TimeZone` for the given ID.

  Specified by:
    `getInstance` in class `TimeZoneImplementation`
  Parameters:
    `ID` - the ID for a `TimeZone`, either an abbreviation such as "GMT", or a full name such as "America/Los_Angeles".

    The only time zone ID that is required to be supported is "GMT", though typically, the timezones for the regions where the device is sold should be supported.

  Returns:
    the specified `TimeZone`, or null if the given ID cannot be understood.

### getIDs

    public String[] getIDs()

  Gets all the available IDs supported.

  Specified by:
    `getIDs` in class `TimeZoneImplementation`
  Returns:
    an array of IDs.

### equals

    public boolean equals(Object object)

  Indicates whether some other object is "equal to" this one.

  The `equals` method implements an equivalence relation on non-null object references:

  - It is reflexive: for any non-null reference value `x`, `x.equals(x)` should return `true`.
  - It is symmetric: for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
  - It is transitive: for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
  - It is consistent: for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
  - For any non-null reference value `x`, `x.equals(null)` should return `false`.

  The `equals` method for class `Object` implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values `x` and `y`, this method returns `true` if and only if `x` and `y` refer to the same object (`x == y` has the value `true`).

  Note that it is generally necessary to override the `hashCode` method whenever this method is overridden, so as to maintain the general contract for the `hashCode` method, which states that equal objects must have equal hash codes.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `object` - the reference object with which to compare.
  Returns:
    `true` if this object is the same as the obj argument; `false` otherwise.
  See Also:
    `hashCode()`, `Hashtable`

### hashCode

    public int hashCode()

  Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by `java.util.Hashtable`.

  The general contract of `hashCode` is:

  - Whenever it is invoked on the same object more than once during an execution of a Java application, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  - If two objects are equal according to the `equals(Object)` method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
  - It is not required that if two objects are unequal according to the `Object.equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

  As much as is reasonably practical, the hashCode method defined by class `Object` does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

  Overrides:
    `hashCode` in class `Object`
  Returns:
    a hash code value for this object.
  See Also:
    `Object.equals(java.lang.Object)`, `Hashtable`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| " 2013 FRC Java API "
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

"
For updated information see the Java FRC site
"