fipaos.util
Class UTCTime

java.lang.Object
  |
  +--fipaos.util.UTCContainer
        |
        +--fipaos.util.UTCTime
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class UTCTime
extends UTCContainer
implements java.lang.Cloneable, java.io.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


See Also:
Serialized Form

Fields inherited from class fipaos.util.UTCContainer
_date_data, _use_millis, _use_seconds, DATE, HOUR, MILLISECOND, MINUTE, MONTH, SECOND, YEAR
 
Constructor Summary
UTCTime()
          Constructs a UTCTime object to represent the current time
UTCTime(int year, int month, int date, int hour, int minute, int second, int millis, java.lang.String time_zone)
          Constructs a UTCTime object from the given parameters
UTCTime(java.lang.String time)
          Constructs a UTCTime object given a UTC string of the form 19990427T1200Z or 19990427T120000Z.
 
Method Summary
 void add(int field, int value)
          Method to allow addition/subtraction from an element of the date
 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
 void changeTimeZone(java.lang.String new_zone)
          Change timezone from the current to the one specified.
 boolean equals(UTCTime time)
          Method to provide a mechanism for determining if two times are the same
 int getDayOfWeek()
          returns the day of the week as an integer sunday - 1, monday - 2 .....saturday - 7
 long getTimeInMillis()
          Returns the number of milliseconds since 19700101T0000 in the timezone of this UTCTime object
 java.lang.String getTimeZone()
          Method to retreive the timezone of the UTCTime object
 UTCTime getZTime()
          Method to return a representation of this object in Z time
 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.
 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
static void main(java.lang.String[] args)
           
 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
 void setTimeZone(java.lang.String timezone)
          Method to allow change of timezone
 java.lang.String toString()
          Overrides default Object.toString()
 
Methods inherited from class fipaos.util.UTCContainer
clone, equals, get, isAfter, isBefore, setAccuracy
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UTCTime

public UTCTime(java.lang.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,
               java.lang.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

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
Overrides:
set in class UTCContainer
Parameters:
field - The field which is to be changed
value - The new value to set the field to

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

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

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

setTimeZone

public void setTimeZone(java.lang.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

getTimeZone

public java.lang.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

changeTimeZone

public void changeTimeZone(java.lang.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

getTimeInMillis

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

toString

public java.lang.String toString()
Overrides default Object.toString()
Overrides:
toString in class UTCContainer

getDayOfWeek

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

main

public static void main(java.lang.String[] args)