fipaos.util
Class UTCTime

fipaos.util.UTCContainer
  |
  +--fipaos.util.UTCTime

public class UTCTime
extends UTCContainer
implements Cloneable, Serializable

This is a class which can be used to directly manipulate UTC
time strings in a consitant manner. Due to the unreliablility
of information about which timezone the user is in from Java,
details of the local timezone are picked up from a user.profile
file in the currect directory (this is not an ideal solution
since the information should really come from some form of roaming
profile). An example of the user.profile file is given below

User profile. Includes user specific information about
the timezone they are working in (at a future date this
should be picked up from the user's roaming profile)

Local timezone offset from Z (GMT) excluding DST

TimeZoneOffset = 0


Offset from normal local timezone during DST
If this is omitted or == 0, DST is not used

DSTOffset = 1.0



Details about when DST should start



DSTStartMonth indicates the starting month of DST, and should
be in the range 1 to 12



DSTStartWeekOfMonth indicates which week of the month DST should
start. Negative values are relative to the end of the month.



DSTStartDayOfWeek indicates which day of the week DST should start.
This should be in the range 0 to 6, with 0 being Sunday and 6 being
Saturday (e.g. 2 = Tuesday)



DSTStartHourOfDay indicates at which hour of the day (24 hour format)
the change should occur. This should be in the range 0 to 23


DSTStartMonth = 3

DSTStartWeekOfMonth = -1

DSTStartDayOfWeek = 0

DSTStartHourOfDay = 2



Details about when DST should end. Similar to DSTStart
properties above


DSTEndMonth = 10

DSTEndWeekOfMonth = -1

DSTEndDayOfWeek = 0

DSTEndHourOfDay = 2



Use of set method

a problem can occur when setting the MONTH attibute

if the DATE attribute is after the last day of the month eg.30th when the

month is February this will have the effect of incrementing the month

this can be avoided bysetting the DATE atribute to below the last day of the MONTH

before setting the MONTH attribute






Fields inherited from class fipaos.util.UTCContainer
DATE, HOUR, MILLISECOND, MINUTE, MONTH, SECOND, YEAR

Constructor Summary
UTCTime(String time)
          Constructs a UTCTime object given a UTC string of the
form 19990427T1200Z or 19990427T120000Z.
UTCTime(int year, int month, int date, int hour, int minute, int second, int millis, String time_zone)
          Constructs a UTCTime object from the given parameters
UTCTime()
          Constructs a UTCTime object to represent the current time

Method Summary
 voidadd(int field, int value)
          Method to allow addition/subtraction from an element of the
date
 voidaddDuration(UTCDuration duration)
          Method to allow addition of a UTCDuration to this UTCTime object
Fields are added from least significant to most significant field
 voidchangeTimeZone(String new_zone)
          Change timezone from the current to the one specified.
 booleanequals(UTCTime time)
          Method to provide a mechanism for determining if two times are the same
 intgetDayOfWeek()
          returns the day of the week as an integer sunday - 1, monday - 2 .....saturday - 7
 longgetTimeInMillis()
          Returns the number of milliseconds since 19700101T0000
in the timezone of this UTCTime object
 StringgetTimeZone()
          Method to retreive the timezone of the UTCTime object
 UTCTimegetZTime()
          Method to return a representation of this object in
Z time
 booleanisAfter(UTCTime time)
          Method to provide a way of determining if a UTCTime object represents a time before
the time this UTCTime instance represents.
 booleanisBefore(UTCTime time)
          Method to provide a way of determining if a UTCTime object represents a time after
the time this UTCTime instance represents
 static voidmain(String[] args)
           
 voidset(int field, int value)
          Method to allow manual setting of date/time fields
All fields will be re-validated before this method
returns
 voidsetTimeZone(String timezone)
          Method to allow change of timezone
 StringtoString()
          Overrides default Object.toString()

Methods inherited from class fipaos.util.UTCContainer
clone, equals, get, isAfter, isBefore, setAccuracy

Constructor Detail

UTCTime

public UTCTime(String time)
Constructs a UTCTime object given a UTC string of the
form 19990427T1200Z or 19990427T120000Z. If the time zone
is ommited, the local time zone is assumed. Seconds and
milliseconds may not need to be specified. If the string is
prefixed with a + the time is taken to be relative to the
present time.
Parameters:
time - A UTC time string of the form YYYYMMDDTHHMMZ or
YYYYMMDDTHHMMSSMMMZ where YYYY=year, MM=month, DD=date,
HH=hour, second MM = minutes, SS = seconds, MMM = millisecond
and Z=timezone

UTCTime

public UTCTime(int year, int month, int date, int hour, int minute, int second, int millis, String time_zone)
Constructs a UTCTime object from the given parameters
Parameters:
year - The year
month - The month (1 to 12)
date - The day of the month (1 to (28 thru 31))
hour - The hour of the day (0 to 23)
minute - The minute of the hour (0 to 59)
second - The second of the minute (0 to 59, or -1 to ignore minutes)
millis - The millisecond of the second (0 to 999, or -1 to ignore millis)
time_zone - Letter representing the timezone
If this is null, the local time zone is assumed

UTCTime

public UTCTime()
Constructs a UTCTime object to represent the current time
Method Detail

add

public void add(int field, int value)
Method to allow addition/subtraction from an element of the
date
Parameters:
field - The field of the UTCTime object to change
value - The value to add to the element (use negative values
to subtract)

addDuration

public void addDuration(UTCDuration duration)
Method to allow addition of a UTCDuration to this UTCTime object
Fields are added from least significant to most significant field
Parameters:
duration - The duration to add to this UTCTime

changeTimeZone

public void changeTimeZone(String new_zone)
Change timezone from the current to the one specified.
Also changes the time accordingly
Parameters:
new_zone - A string representing the new timezone

equals

public boolean equals(UTCTime time)
Method to provide a mechanism for determining if two times are the same
Parameters:
time - The time to compare

getDayOfWeek

public int getDayOfWeek()
returns the day of the week as an integer sunday - 1, monday - 2 .....saturday - 7

getTimeInMillis

public long getTimeInMillis()
Returns the number of milliseconds since 19700101T0000
in the timezone of this UTCTime object

getTimeZone

public String getTimeZone()
Method to retreive the timezone of the UTCTime object
Returns: A string representing the timezone of the UTCTime object,
a letter in the range A to Z

getZTime

public UTCTime getZTime()
Method to return a representation of this object in
Z time

isAfter

public boolean isAfter(UTCTime time)
Method to provide a way of determining if a UTCTime object represents a time before
the time this UTCTime instance represents.
Parameters:
time - A UTCTime object to compare

isBefore

public boolean isBefore(UTCTime time)
Method to provide a way of determining if a UTCTime object represents a time after
the time this UTCTime instance represents
Parameters:
time - A UTCTime object to compare

main

public static void main(String[] args)

set

public void set(int field, int value)
Method to allow manual setting of date/time fields
All fields will be re-validated before this method
returns
Parameters:
field - The field which is to be changed
value - The new value to set the field to

setTimeZone

public void setTimeZone(String timezone)
Method to allow change of timezone
Parameters:
timezone - A string representing the timezone to change to,
a letter in the range A to Z

toString

public String toString()
Overrides default Object.toString()

Association Links

to Class java.lang.String

List of timezones

to Class java.util.Hashtable

Hashtable of timezones to offsets

to Class java.lang.String

String to denote which timezone this time represents