DCT Lightfoot v3 API specification

java.util
Class Calendar

java.lang.Object
  |
  +--java.util.Calendar
Direct Known Subclasses:
SimpleCalendar

public abstract class Calendar
extends Object

This is a utility class for storing time in a useful format
(Currently only supports Gregorian time)


Field Summary
static int AM
          AM ranges from 00:00 on a 24 hour clock
static int AM_PM
           
static int APRIL
           
static int AUGUST
           
static int DATE
           
static int DAY_OF_MONTH
           
static int DAY_OF_WEEK
           
static int DECEMBER
           
static int FEBRUARY
           
protected  int[] fields
          The array that holds the field data
static int FRIDAY
           
static int HOUR
           
static int HOUR_OF_DAY
           
static int JANUARY
           
static int JULY
           
static int JUNE
           
static int MARCH
           
static int MAY
           
static int MILLISECOND
           
static int MINUTE
           
static int MONDAY
           
static int MONTH
           
static int NOVEMBER
           
static int OCTOBER
           
static int PM
          PM ranges from 12:00 on a 24 hour clock
static int SATURDAY
           
static int SECOND
           
static int SEPTEMBER
           
static int SUNDAY
           
static int THURSDAY
           
protected  long time
          The time value, which is the number of milliseconds since Jan 1, 1970 This is always kept up to date
static int TUESDAY
           
static int WEDNESDAY
           
static int YEAR
           
 
Constructor Summary
protected Calendar()
          Constructs a Calendar with the default time zone and default locale.
 
Method Summary
 boolean after(Object cal2)
          Compares the 'raw' UTC time in this Calendar with the UTC time of the given Calendar (non-Calendar objects return false) and return true if this Calendar is 'later' than the given Calendar.
 boolean before(Object cal2)
          Compares the 'raw' UTC time in this Calendar with the UTC time of the given Calendar (non-Calendar objects return false) and return true if this Calendar is 'earlier' than the given Calendar
protected abstract  void computeFields()
          Set the field values from the current time
protected abstract  void computeTime()
          Set the time from the current field values
 boolean equals(Object obj)
          Returns true if the given object represents a Calendar with the same time value as this one.
 int get(int field)
          Gets the value of the given field.
static Calendar getInstance()
          Gets a calendar using the default time zone and default locale.
(com.dctl.j2me.date.GMTCalendar and
com.dctl.j2me.date.GMTTimeZone
static Calendar getInstance(TimeZone zone)
          Gets a calendar using the specified time zone and default locale.
 Date getTime()
          Get the current time of this Calendar.
protected  long getTimeInMillis()
          Gets this Calendar's current time as a long expressed in milliseconds after January 1, 1970, 0:00:00 GMT (the epoch).
 TimeZone getTimeZone()
          Gets the time zone object
 void set(int field, int value)
          Sets the time field (except DAY_OF_WEEK) with the given value.
 void setTime(Date date)
          Sets the current time using the given Date
protected  void setTimeInMillis(long millis)
          Sets the current time from the given value
 void setTimeZone(TimeZone value)
          Sets the time zone to the given zone
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YEAR

public static final int YEAR
See Also:
Constant Field Values

MONTH

public static final int MONTH
See Also:
Constant Field Values

DATE

public static final int DATE
See Also:
Constant Field Values

DAY_OF_MONTH

public static final int DAY_OF_MONTH
See Also:
Constant Field Values

DAY_OF_WEEK

public static final int DAY_OF_WEEK
See Also:
Constant Field Values

AM_PM

public static final int AM_PM
See Also:
Constant Field Values

HOUR

public static final int HOUR
See Also:
Constant Field Values

HOUR_OF_DAY

public static final int HOUR_OF_DAY
See Also:
Constant Field Values

MINUTE

public static final int MINUTE
See Also:
Constant Field Values

SECOND

public static final int SECOND
See Also:
Constant Field Values

MILLISECOND

public static final int MILLISECOND
See Also:
Constant Field Values

SUNDAY

public static final int SUNDAY
See Also:
Constant Field Values

MONDAY

public static final int MONDAY
See Also:
Constant Field Values

TUESDAY

public static final int TUESDAY
See Also:
Constant Field Values

WEDNESDAY

public static final int WEDNESDAY
See Also:
Constant Field Values

THURSDAY

public static final int THURSDAY
See Also:
Constant Field Values

FRIDAY

public static final int FRIDAY
See Also:
Constant Field Values

SATURDAY

public static final int SATURDAY
See Also:
Constant Field Values

JANUARY

public static final int JANUARY
See Also:
Constant Field Values

FEBRUARY

public static final int FEBRUARY
See Also:
Constant Field Values

MARCH

public static final int MARCH
See Also:
Constant Field Values

APRIL

public static final int APRIL
See Also:
Constant Field Values

MAY

public static final int MAY
See Also:
Constant Field Values

JUNE

public static final int JUNE
See Also:
Constant Field Values

JULY

public static final int JULY
See Also:
Constant Field Values

AUGUST

public static final int AUGUST
See Also:
Constant Field Values

SEPTEMBER

public static final int SEPTEMBER
See Also:
Constant Field Values

OCTOBER

public static final int OCTOBER
See Also:
Constant Field Values

NOVEMBER

public static final int NOVEMBER
See Also:
Constant Field Values

DECEMBER

public static final int DECEMBER
See Also:
Constant Field Values

AM

public static final int AM
AM ranges from 00:00 on a 24 hour clock

See Also:
Constant Field Values

PM

public static final int PM
PM ranges from 12:00 on a 24 hour clock

See Also:
Constant Field Values

time

protected long time
The time value, which is the number of milliseconds since Jan 1, 1970 This is always kept up to date


fields

protected int[] fields
The array that holds the field data

Constructor Detail

Calendar

protected Calendar()
Constructs a Calendar with the default time zone and default locale.

Method Detail

after

public boolean after(Object cal2)
Compares the 'raw' UTC time in this Calendar with the UTC time of the given Calendar (non-Calendar objects return false) and return true if this Calendar is 'later' than the given Calendar.

Parameters:
cal2 - another Calendar
Returns:
true if the current time of this Calendar is before the time of the given Calendar, false otherwise.

before

public boolean before(Object cal2)
Compares the 'raw' UTC time in this Calendar with the UTC time of the given Calendar (non-Calendar objects return false) and return true if this Calendar is 'earlier' than the given Calendar

Parameters:
cal2 - another Calendar
Returns:
true if the current time of this Calendar is before the time of the given Calendar, false otherwise.

equals

public boolean equals(Object obj)
Returns true if the given object represents a Calendar with the same time value as this one.

Overrides:
equals in class Object
Parameters:
obj - the object for comparison
Returns:
true if the objects have the same value, false otherwise

get

public final int get(int field)
Gets the value of the given field. The side effect of this is that the fields are brought up to date prior to the value being returned, so if the date was set to 29th Feb 1973 (not a leap year) then a get of the DATE field would return 1, as the date would have been rationalised to the 1st March 1973. This is an expensive call the first time it is made after the calendar has been created or modified as the fields must be calculated. Subsequent calls simply return values and are therefore very quick.

Returns:
the field value.
Throws:
ArrayIndexOutOfBoundsException - an invalid parameter is given

getInstance

public static Calendar getInstance()
Gets a calendar using the default time zone and default locale.
(com.dctl.j2me.date.GMTCalendar and
com.dctl.j2me.date.GMTTimeZone

Returns:
the default GMT Calendar.

getInstance

public static Calendar getInstance(TimeZone zone)
Gets a calendar using the specified time zone and default locale.

Parameters:
zone - the time zone to use
Returns:
a Calendar.

getTime

public final Date getTime()
Get the current time of this Calendar.

Returns:
the current time.

getTimeInMillis

protected long getTimeInMillis()
Gets this Calendar's current time as a long expressed in milliseconds after January 1, 1970, 0:00:00 GMT (the epoch).

Returns:
the current time as UTC milliseconds from the epoch.

getTimeZone

public TimeZone getTimeZone()
Gets the time zone object

Returns:
the time zone

set

public final void set(int field,
                      int value)
Sets the time field (except DAY_OF_WEEK) with the given value.

Permissible Values


The only fields that allow negative values are :
  1. DATE
  2. DAY_OF_MONTH
  3. MONTH
This method will ignore any negative values for other fields. The fields mentioned above are also the only fields that allow out-of-range values. So setting the DATE to 40 in January will result in the date becoming the 9th Feb: likewise setting the DATE to -1 in February will give a date of 31st Jan. Setting the month to -1 will give a date of December in the previous year. The Calendar ignores requests to set out of range values for any of the other fields (e.g setting the minute to 70 is ignored rather than giving a time of 10 minutes into the next hour).

Time and Date


Setting the time will never alter the date.

Automatic Changing Of Fields

When the set method is called, the field values remain at their given values until the get method is called, or one of the other set methods is called to set the absolute time, in which case the field data is invalidated.

Parameters:
field - the given time field.
The largest supported year is 268435455.
value - the value to be set for the given time field.
Throws:
ArrayIndexOutOfBoundsException - if an illegal field parameter is received.

setTime

public final void setTime(Date date)
Sets the current time using the given Date


setTimeInMillis

protected void setTimeInMillis(long millis)
Sets the current time from the given value


setTimeZone

public void setTimeZone(TimeZone value)
Sets the time zone to the given zone

Parameters:
value - the given time zone.

computeFields

protected abstract void computeFields()
Set the field values from the current time


computeTime

protected abstract void computeTime()
Set the time from the current field values


DCT Lightfoot v3 API specification

DCT Lightfoot v3 API specification