sgtplot.util
Class GeoDate
- java.lang.Object
-
- java.util.Date
-
- sgtplot.util.GeoDate
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>
public class GeoDate extends java.util.Date implements java.io.SerializableGeoDateextends the capabilities ofDate. Additional features ofGeoDateinclude methods for incrementing and decrementing, adding and substractingGeoDateobjects. AllGeoDateobjects share the sameGregorianCalendarset to a "GMT" time zone. Thus, allGeoDatetimes are in "GMT". This simplifies the conversion to and fromStringrepresentations of time.- Since:
- sgtplot 1.0
- See Also:
GregorianCalendar, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intDAYSIncrement or decrement in days.static intHOURSIncrement or decrement in hours.static intMINUTESIncrement or decrement in minutesstatic intMONTHSIncrement or decrement in months.static intMSECIncrement or decrement in millisecondsstatic longMSECS_IN_DAYNumber of milliseconds in a day.static intSECONDSIncrement or decrement in seondsstatic intYEARSIncrement or decrement in years.
-
Constructor Summary
Constructors Constructor and Description GeoDate()Construct a newGeoDate.GeoDate(java.util.Date date)Construct a newGeoDatefrom aDateobject.GeoDate(GeoDate t)Constructs a newGeoDatefrom an existingGeoDate.GeoDate(int jday, int msec)Construct a newGeoDatefrom EPIC double integers.GeoDate(int mon, int day, int year, int hour, int min, int sec, int msec)Construct a newGeoDatefrom 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 newGeoDatefrom aString.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description GeoDateadd(GeoDate time)Add time to currentGeoDate.intcompareTo(GeoDate anotherDate)Tests to see if the current GeoDate is less than, equal, or greater than.GeoDatedecrement(double val, int tu)Decrement currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARSGeoDatedecrement(float val, int tu)Decrement currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARSGeoDatedivide(double val)Divide by value.java.util.CalendargetCalendar()Get a reference to theGregorianCalendarset to the currentGeoDatetime.intgetDay()Deprecated.Overrides a deprecated method, replaced bygetGMTDay().intgetDaysInMonth()Get the number of days in the current month.intgetGMTDay()Get dayintgetGMTHours()Get hoursintgetGMTMinutes()Get minutesintgetGMTMonth()Get monthdoublegetGMTSeconds()Get seconds and fraction of seconds.intgetGMTYear()Get year.intgetHours()Deprecated.Overrides a deprecated method, replaced bygetGMTHours().intgetJDay()get EPIC Julian DayintgetMinutes()Deprecated.Overrides a deprecated method, replaced bygetGMTMinutes().intgetMonth()Deprecated.Overrides a deprecated method, replaced bygetGMTMonth().intgetMSec()get milliseconds since midnightdoublegetSecondss()Deprecated.replaced bygetGMTSeconds().intgetYear()Deprecated.Overrides a deprecated method, replaced bygetGMTYear().intgetYearday()Get year-day number (Jan 1 = 1)GeoDateincrement(double val, int tu)Increment currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARSGeoDateincrement(float val, int tu)Increment currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARSbooleanisMissing()Tests to see if value represents missing data.booleanisRelativeTime()Tests the relativeTime flag.voidnow()Set to current time.doubleoffset(GeoDate ref)Time offset from referenceGeoDatevoidset(int jday, int msec)Change value ofGeoDatefrom EPIC double integers.voidset(int mon, int day, int year, int hour, int min, int sec, int msec)Change value ofGeoDatefrom values.voidsetRelativeTime(boolean relative)Set the relativeTime flag.voidsetYearYearDay(int year, int yearday)Set aGeoDatefrom year and year-day.GeoDatesubtract(GeoDate time2)Subtract time2 from currentGeoDate.java.lang.StringtoString()ConvertGeoDatetoStringusing standard format "yyyy-MM-dd HH:mm:ss z" and "GMT" time zone.java.lang.StringtoString(java.lang.String format)ConvertGeoDatetoStringusing provided format.
-
-
-
Field Detail
-
DAYS
public static final int DAYS
Increment or decrement in days.- See Also:
- Constant Field Values
-
MONTHS
public static final int MONTHS
Increment or decrement in months.- See Also:
- Constant Field Values
-
YEARS
public static final int YEARS
Increment or decrement in years.- See Also:
- Constant Field Values
-
HOURS
public static final int HOURS
Increment or decrement in hours.- See Also:
- Constant Field Values
-
MINUTES
public static final int MINUTES
Increment or decrement in minutes- See Also:
- Constant Field Values
-
SECONDS
public static final int SECONDS
Increment or decrement in seonds- See Also:
- Constant Field Values
-
MSEC
public static final int MSEC
Increment or decrement in milliseconds- See Also:
- Constant Field Values
-
MSECS_IN_DAY
public static final long MSECS_IN_DAY
Number of milliseconds in a day.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GeoDate
public GeoDate()
Construct a newGeoDate.
-
GeoDate
public GeoDate(java.lang.String time, java.lang.String format) throws IllegalTimeValueConstruct a newGeoDatefrom aString. Formatting is done usingSimpleDateFormat. The specified time is taken to be "GMT".- Parameters:
time- character representation of timeformat- codes used to read time- Throws:
IllegalTimeValue
-
GeoDate
public GeoDate(GeoDate t)
Constructs a newGeoDatefrom an existingGeoDate.- Parameters:
t-GeoDate
-
GeoDate
public GeoDate(int mon, int day, int year, int hour, int min, int sec, int msec) throws IllegalTimeValueConstruct a newGeoDatefrom values. The specified time is taken to be "GMT".- Parameters:
mon- monthday- day of the monthyear- year (no offset!)hour- hourmin- minutessec- secondsmsec- 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 newGeoDatefrom aDateobject. No time zone conversion is done.- Parameters:
date- Date object
-
GeoDate
public GeoDate(int jday, int msec)Construct a newGeoDatefrom EPIC double integers. Time zone for conversion is "GMT".- Parameters:
jday- julian daymsec- 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 theGeoDateobject 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 ofGeoDatefrom EPIC double integers. Time zone for conversion is "GMT".- Parameters:
jday- julian daymsec- milliseconds since midnight
-
set
public void set(int mon, int day, int year, int hour, int min, int sec, int msec) throws IllegalTimeValueChange value ofGeoDatefrom values. Time zone for conversion is "GMT".- Parameters:
mon- month (1=January, 12=December)day- day of the monthyear- year (no offset!)hour- hourmin- minutessec- secondsmsec- 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 currentGeoDate. This operation only makes since iftimeis a relative time value, i.e. the result of aGeoDatesubrtraction.- Parameters:
time-GeoDate- Returns:
- new
GeoDate
-
subtract
public GeoDate subtract(GeoDate time2)
Subtract time2 from currentGeoDate.- 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 currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS- Parameters:
val- amount to incrementtu- time units (SECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS) operation.
-
increment
public GeoDate increment(double val, int tu)
Increment currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS- Parameters:
val- amount to incrementtu- time units (SECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS) operation.
-
decrement
public GeoDate decrement(float val, int tu)
Decrement currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS- Parameters:
val- amount to decrementtu- time units (SECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS) operation.
-
decrement
public GeoDate decrement(double val, int tu)
Decrement currentGeoDatebySECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS- Parameters:
val- amount to decrementtu- time units (SECONDS,MINUTES,HOURS,DAYS,MONTHS, orYEARS) operation.
-
offset
public double offset(GeoDate ref)
Time offset from referenceGeoDate- Parameters:
ref- referenceGeoDate- Returns:
- offset in days
-
setYearYearDay
public void setYearYearDay(int year, int yearday)Set aGeoDatefrom year and year-day.- Parameters:
year- yearyearday- 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 theGregorianCalendarset to the currentGeoDatetime.- Returns:
Calendar
-
getYearday
public int getYearday()
Get year-day number (Jan 1 = 1)
-
getYear
public int getYear()
Deprecated. Overrides a deprecated method, replaced bygetGMTYear().Get year- Overrides:
getYearin classjava.util.Date
-
getGMTYear
public int getGMTYear()
Get year.
-
getMonth
public int getMonth()
Deprecated. Overrides a deprecated method, replaced bygetGMTMonth().Get month- Overrides:
getMonthin classjava.util.Date
-
getGMTMonth
public int getGMTMonth()
Get month
-
getDay
public int getDay()
Deprecated. Overrides a deprecated method, replaced bygetGMTDay().Get day- Overrides:
getDayin classjava.util.Date
-
getGMTDay
public int getGMTDay()
Get day
-
getHours
public int getHours()
Deprecated. Overrides a deprecated method, replaced bygetGMTHours().Get hours- Overrides:
getHoursin classjava.util.Date
-
getGMTHours
public int getGMTHours()
Get hours
-
getMinutes
public int getMinutes()
Deprecated. Overrides a deprecated method, replaced bygetGMTMinutes().Get minutes- Overrides:
getMinutesin classjava.util.Date
-
getGMTMinutes
public int getGMTMinutes()
Get minutes
-
getSecondss
public double getSecondss()
Deprecated. replaced bygetGMTSeconds().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()
ConvertGeoDatetoStringusing standard format "yyyy-MM-dd HH:mm:ss z" and "GMT" time zone.- Overrides:
toStringin classjava.util.Date- Returns:
- date
-
toString
public java.lang.String toString(java.lang.String format)
ConvertGeoDatetoStringusing provided format. TheSimpleDateFormatand theGregorianCalendaris used to format theGeoDate. 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 ofLong.MIN_VALUErepresents 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
-
-
DMelt 3.0 © DataMelt by jWork.ORG