gov.noaa.pmel.util
Class GeoDate

java.lang.Object
  |
  +--java.util.Date
        |
        +--gov.noaa.pmel.util.GeoDate
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

public class GeoDate
extends java.util.Date
implements java.io.Serializable

GeoDate extends the capabilities of Date. Additional features of GeoDate include methods for incrementing and decrementing, adding and substracting GeoDate objects. All GeoDate objects share the same GregorianCalendar set to a "GMT" time zone. Thus, all GeoDate times are in "GMT". This simplifies the conversion to and from String representations of time.

Since:
sgt 1.0
Version:
$Revision: 1.16 $, $Date: 2001/07/10 17:25:15 $
Author:
Donald Denbo
See Also:
GregorianCalendar, Serialized Form

Field Summary
static int DAYS
          Increment or decrement in days.
static int HOURS
          Increment or decrement in hours.
static int MINUTES
          Increment or decrement in minutes
static int MONTHS
          Increment or decrement in months.
static int MSEC
          Increment or decrement in milliseconds
static long MSECS_IN_DAY
          Number of milliseconds in a day.
static int SECONDS
          Increment or decrement in seonds
static int YEARS
          Increment or decrement in years.
 
Constructor Summary
GeoDate()
          Construct a new GeoDate.
GeoDate(java.util.Date date)
          Construct a new GeoDate from a Date object.
GeoDate(GeoDate t)
          Constructs a new GeoDate from an existing GeoDate.
GeoDate(int jday, int msec)
          Construct a new GeoDate from EPIC double integers.
GeoDate(int mon, int day, int year, int hour, int min, int sec, int msec)
          Construct a new GeoDate from values.
GeoDate(long date)
          Allocates a GeoDate object and initializes it to represent the specified number of milliseconds since the standard base time know as "the epoch", namely January 1, 1970, 00:00:00 GMT.
GeoDate(java.lang.String time, java.lang.String format)
          Construct a new GeoDate from a String.
 
Method Summary
 GeoDate add(GeoDate time)
          Add time to current GeoDate.
 int compareTo(GeoDate anotherDate)
          Tests to see if the current GeoDate is less than, equal, or greater than.
 GeoDate decrement(double val, int tu)
          Decrement current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
 GeoDate decrement(float val, int tu)
          Decrement current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
 GeoDate divide(double val)
          Divide by value.
 java.util.Calendar getCalendar()
          Get a reference to the GregorianCalendar set to the current GeoDate time.
 int getDay()
          Deprecated. Overrides a deprecated method, replaced by getGMTDay().
 int getDaysInMonth()
          Get the number of days in the current month.
 int getGMTDay()
          Get day
 int getGMTHours()
          Get hours
 int getGMTMinutes()
          Get minutes
 int getGMTMonth()
          Get month
 double getGMTSeconds()
          Get seconds and fraction of seconds.
 int getGMTYear()
          Get year.
 int getHours()
          Deprecated. Overrides a deprecated method, replaced by getGMTHours().
 int getJDay()
          get EPIC Julian Day
 int getMinutes()
          Deprecated. Overrides a deprecated method, replaced by getGMTMinutes().
 int getMonth()
          Deprecated. Overrides a deprecated method, replaced by getGMTMonth().
 int getMSec()
          get milliseconds since midnight
 double getSecondss()
          Deprecated. replaced by getGMTSeconds().
 int getYear()
          Deprecated. Overrides a deprecated method, replaced by getGMTYear().
 int getYearday()
          Get year-day number (Jan 1 = 1)
 GeoDate increment(double val, int tu)
          Increment current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
 GeoDate increment(float val, int tu)
          Increment current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
 boolean isMissing()
          Tests to see if value represents missing data.
 boolean isRelativeTime()
          Tests the relativeTime flag.
 void now()
          Set to current time.
 double offset(GeoDate ref)
          Time offset from reference GeoDate
 void set(int jday, int msec)
          Change value of GeoDate from EPIC double integers.
 void set(int mon, int day, int year, int hour, int min, int sec, int msec)
          Change value of GeoDate from values.
 void setRelativeTime(boolean relative)
          Set the relativeTime flag.
 void setYearYearDay(int year, int yearday)
          Set a GeoDate from year and year-day.
 GeoDate subtract(GeoDate time2)
          Subtract time2 from current GeoDate.
 java.lang.String toString()
          Convert GeoDate to String using standard format "yyyy-MM-dd HH:mm:ss z" and "GMT" time zone.
 java.lang.String toString(java.lang.String format)
          Convert GeoDate to String using provided format.
 
Methods inherited from class java.util.Date
after, before, clone, compareTo, compareTo, equals, getDate, getSeconds, getTime, getTimezoneOffset, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toLocaleString, UTC
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DAYS

public static final int DAYS
Increment or decrement in days.

MONTHS

public static final int MONTHS
Increment or decrement in months.

YEARS

public static final int YEARS
Increment or decrement in years.

HOURS

public static final int HOURS
Increment or decrement in hours.

MINUTES

public static final int MINUTES
Increment or decrement in minutes

SECONDS

public static final int SECONDS
Increment or decrement in seonds

MSEC

public static final int MSEC
Increment or decrement in milliseconds

MSECS_IN_DAY

public static final long MSECS_IN_DAY
Number of milliseconds in a day.
Constructor Detail

GeoDate

public GeoDate()
Construct a new GeoDate.

GeoDate

public GeoDate(java.lang.String time,
               java.lang.String format)
        throws IllegalTimeValue
Construct a new GeoDate from a String. Formatting is done using SimpleDateFormat. The specified time is taken to be "GMT".
Parameters:
time - character representation of time
format - codes used to read time

GeoDate

public GeoDate(GeoDate t)
Constructs a new GeoDate from an existing GeoDate.
Parameters:
t - GeoDate

GeoDate

public GeoDate(int mon,
               int day,
               int year,
               int hour,
               int min,
               int sec,
               int msec)
        throws IllegalTimeValue
Construct a new GeoDate from values. The specified time is taken to be "GMT".
Parameters:
mon - month
day - day of the month
year - year (no offset!)
hour - hour
min - minutes
sec - seconds
msec - milliseconds
Throws:
IllegalTimeValue - The constructor was called with a set of parameters that does not constitute a legitimate time value.

GeoDate

public GeoDate(java.util.Date date)
Construct a new GeoDate from a Date object. No time zone conversion is done.
Parameters:
date - Date object

GeoDate

public GeoDate(int jday,
               int msec)
Construct a new GeoDate from EPIC double integers. Time zone for conversion is "GMT".
Parameters:
jday - julian day
msec - milliseconds since midnight

GeoDate

public GeoDate(long date)
Allocates a GeoDate object and initializes it to represent the specified number of milliseconds since the standard base time know as "the epoch", namely January 1, 1970, 00:00:00 GMT.
Method Detail

setRelativeTime

public void setRelativeTime(boolean relative)
Set the relativeTime flag. The relativeTime flag indicates that the GeoDate object does not represent an actual absolute time, but a temporal duration.

isRelativeTime

public boolean isRelativeTime()
Tests the relativeTime flag.
Returns:
if true, time is a duration

set

public void set(int jday,
                int msec)
Change value of GeoDate from EPIC double integers. Time zone for conversion is "GMT".
Parameters:
jday - julian day
msec - milliseconds since midnight

set

public void set(int mon,
                int day,
                int year,
                int hour,
                int min,
                int sec,
                int msec)
         throws IllegalTimeValue
Change value of GeoDate from values. Time zone for conversion is "GMT".
Parameters:
mon - month (1=January, 12=December)
day - day of the month
year - year (no offset!)
hour - hour
min - minutes
sec - seconds
msec - milliseconds
Throws:
IllegalTimeValue - The parameters passed to this method represent a time value that is invalid

getDaysInMonth

public int getDaysInMonth()
Get the number of days in the current month.
Returns:
number of days in current month

now

public void now()
Set to current time.

add

public GeoDate add(GeoDate time)
Add time to current GeoDate. This operation only makes since if time is a relative time value, i.e. the result of a GeoDate subrtraction.
Parameters:
time - GeoDate
Returns:
new GeoDate

subtract

public GeoDate subtract(GeoDate time2)
Subtract time2 from current GeoDate.
Parameters:
time2 - subtracthend
Returns:
new GeoDate

divide

public GeoDate divide(double val)
Divide by value. Current time should the result of adding two times or subtracting two times to be a meaningful calculation.
Parameters:
val - divisor
Returns:
new GeoDate

increment

public GeoDate increment(float val,
                         int tu)
Increment current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
Parameters:
val - amount to increment
tu - time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) operation.

increment

public GeoDate increment(double val,
                         int tu)
Increment current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
Parameters:
val - amount to increment
tu - time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) operation.

decrement

public GeoDate decrement(float val,
                         int tu)
Decrement current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
Parameters:
val - amount to decrement
tu - time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) operation.

decrement

public GeoDate decrement(double val,
                         int tu)
Decrement current GeoDate by SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS
Parameters:
val - amount to decrement
tu - time units (SECONDS, MINUTES, HOURS, DAYS, MONTHS, or YEARS) operation.

offset

public double offset(GeoDate ref)
Time offset from reference GeoDate
Parameters:
ref - reference GeoDate
Returns:
offset in days

setYearYearDay

public void setYearYearDay(int year,
                           int yearday)
Set a GeoDate from year and year-day.
Parameters:
year - year
yearday - year-day number (Jan 1 = 1) parameters that does not constitute a legitimate time value.

getCalendar

public java.util.Calendar getCalendar()
Get a reference to the GregorianCalendar set to the current GeoDate time.
Returns:
Calendar

getYearday

public int getYearday()
Get year-day number (Jan 1 = 1)

getYear

public int getYear()
Deprecated. Overrides a deprecated method, replaced by getGMTYear().

Get year
Overrides:
getYear in class java.util.Date
Following copied from class: java.util.Date
Returns:
the year represented by this date, minus 1900.
See Also:
Calendar

getGMTYear

public int getGMTYear()
Get year.

getMonth

public int getMonth()
Deprecated. Overrides a deprecated method, replaced by getGMTMonth().

Get month
Overrides:
getMonth in class java.util.Date
Following copied from class: java.util.Date
Returns:
the month represented by this date.
See Also:
Calendar

getGMTMonth

public int getGMTMonth()
Get month

getDay

public int getDay()
Deprecated. Overrides a deprecated method, replaced by getGMTDay().

Get day
Overrides:
getDay in class java.util.Date
Following copied from class: java.util.Date
Returns:
the day of the week represented by this date.
See Also:
Calendar

getGMTDay

public int getGMTDay()
Get day

getHours

public int getHours()
Deprecated. Overrides a deprecated method, replaced by getGMTHours().

Get hours
Overrides:
getHours in class java.util.Date
Following copied from class: java.util.Date
Returns:
the hour represented by this date.
See Also:
Calendar

getGMTHours

public int getGMTHours()
Get hours

getMinutes

public int getMinutes()
Deprecated. Overrides a deprecated method, replaced by getGMTMinutes().

Get minutes
Overrides:
getMinutes in class java.util.Date
Following copied from class: java.util.Date
Returns:
the number of minutes past the hour represented by this date.
See Also:
Calendar

getGMTMinutes

public int getGMTMinutes()
Get minutes

getSecondss

public double getSecondss()
Deprecated. replaced by getGMTSeconds().

Get secondss

getGMTSeconds

public double getGMTSeconds()
Get seconds and fraction of seconds.

getJDay

public int getJDay()
get EPIC Julian Day

getMSec

public int getMSec()
get milliseconds since midnight

toString

public java.lang.String toString()
Convert GeoDate to String using standard format "yyyy-MM-dd HH:mm:ss z" and "GMT" time zone.
Overrides:
toString in class java.util.Date
Returns:
date

toString

public java.lang.String toString(java.lang.String format)
Convert GeoDate to String using provided format. The SimpleDateFormat and the GregorianCalendar is used to format the GeoDate. A format of "decade" will create a string of the form 1990 or 1980.
Parameters:
format - String containing codes used to write time.
See Also:
SimpleDateFormat

isMissing

public boolean isMissing()
Tests to see if value represents missing data. A value from the getTime() method of Long.MIN_VALUE represents a missing observation.
See Also:
SGTData.getXRange()

compareTo

public int compareTo(GeoDate anotherDate)
Tests to see if the current GeoDate is less than, equal, or greater than. another GeoDate


Send comments about the Scientific Graphics toolkit to dwd@pmel.noaa.gov. For more information about Java Development in the EPIC Group see the EPIC Software Page
Generated on December 13 2001