org.opengts.util
Class DateTime

java.lang.Object
  extended by org.opengts.util.DateTime
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class DateTime
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable

Performs every manner of function imaginable based on date/time values


Nested Class Summary
static class DateTime.DateParseException
          DateParseException class
static class DateTime.DateStringFormat
          Enum to indicate a date string format and to convert from one format to another
static class DateTime.DefaultParsedTime
          Enum indicating how to handle parsed dates when no time is specified
CurrentTime - Use current time
ContextStart - Use start of time context (ie.
static class DateTime.ParsedDateTime
          Class/Structure which holds date/time information
static interface DateTime.TimeZoneProvider
          TimeZoneProvider interface
 
Field Summary
static int APR
           
static int APRIL
           
static int AUG
           
static int AUGUST
           
static long DAYS_PER_WEEK
           
static int DEC
           
static int DECEMBER
           
static java.lang.String DEFAULT_DATE_FORMAT
           
static java.lang.String DEFAULT_DATETIME_FORMAT
           
static java.lang.String DEFAULT_DATETIME_TZ_FORMAT
           
static java.lang.String DEFAULT_TIME_FORMAT
           
static java.lang.String DEFAULT_TIMEZONE_FORMAT
           
static int FEB
           
static int FEBRUARY
           
static int FRI
           
static int FRIDAY
           
static java.util.TimeZone GMT
           
static java.lang.String GMT_TIMEZONE
           
static long HOURS_PER_DAY
           
static double HOURS_PER_MINUTE
           
static double HOURS_PER_SECOND
           
static DateTime INVALID_DATETIME
           
static java.lang.String ISO8601_DATETIME_FORMAT
           
static int JAN
           
static int JANUARY
           
static int JUL
           
static int JULY
           
static int JUN
           
static int JUNE
           
static boolean LOWERCASE_TIMEZONE_LOOKUP
           
static int MAR
           
static int MARCH
           
static DateTime MAX_DATETIME
           
static long MAX_TIMESEC
           
static int MAY
           
static DateTime MIN_DATETIME
           
static long MIN_TIMESEC
           
static long MINUTES_PER_DAY
           
static long MINUTES_PER_HOUR
           
static double MINUTES_PER_SECOND
           
static long MINUTES_PER_WEEK
           
static int MON
           
static int MONDAY
           
static int MONTHS_PER_YEAR
           
static int NOV
           
static int NOVEMBER
           
static int OCT
           
static int OCTOBER
           
static int SAT
           
static int SATURDAY
           
static long SECONDS_PER_DAY
           
static long SECONDS_PER_HOUR
           
static long SECONDS_PER_MINUTE
           
static long SECONDS_PER_WEEK
           
static int SEP
           
static int SEPTEMBER
           
static int SUN
           
static int SUNDAY
           
static int THU
           
static int THURSDAY
           
static int TUE
           
static int TUESDAY
           
static int WED
           
static int WEDNESDAY
           
 
Constructor Summary
DateTime()
          Default constructor.
DateTime(java.util.Date date)
          Constructor.
DateTime(DateTime dt)
          Copy constructor
DateTime(DateTime dt, long deltaOffsetSec)
          Copy constructor with delta offset time
DateTime(java.util.Date date, java.util.TimeZone tz)
          Constructor.
DateTime(long timeSec)
          Constructor.
DateTime(long timeSec, java.util.TimeZone tz)
          Constructor.
DateTime(java.lang.String d)
          Constructor.
DateTime(java.util.TimeZone tz)
          Constructor.
DateTime(java.util.TimeZone tz, int year, int month1, int day)
          Constructor (time is set to Noon)
DateTime(java.util.TimeZone tz, int year, int month1, int day, int hour24, int minute, int second)
          Constructor.
 
Method Summary
protected  java.util.TimeZone _timeZone(java.util.TimeZone tz)
          Returns a non-null TimeZone
 java.lang.Object clone()
          Returns a clone of this DateTime instance
static java.lang.String CompactDateTimeFormat(char sep)
          Returns a compact date/time format
This format can be parsed by the "parseArgumentDate" method if the specified separator is one of ",", " ", or "|".
static java.lang.String CompactDateTimeFormat(java.lang.String sep)
          Returns a compact date/time format
This format can be parsed by the "parseArgumentDate" method if the specified separator is one of ",", " ", or "|".
 int compareTo(java.lang.Object other)
          Compares another DateTime instance to this instance.
static long DaySeconds(double days)
          Returns the number of seconds in the specified number of days
static long DaySeconds(long days)
          Returns the number of seconds in the specified number of days
static java.lang.String encodeHourMinuteSecond(long tod, java.lang.String fmt)
          Formats the time-of-day, based on the specified format.
 boolean equals(java.lang.Object obj)
          Returns true if the specified DateTime is equal-to this DateTime instance
static java.lang.String format(java.util.Date date, java.util.TimeZone tz, java.lang.String dtFmt)
          Formats the specified Date instance.
 java.lang.String format(java.lang.String fmt)
          Formats the current DateTime instance.
 java.lang.String format(java.lang.String fmt, java.util.TimeZone tz)
          Formats the current DateTime instance.
 java.lang.String format(java.lang.String dtFmt, java.util.TimeZone tz, java.lang.StringBuffer sb)
          Formats the current DateTime instance.
 java.lang.String format(java.util.TimeZone tz)
          Formats the current DateTime instance (using format "MMM dd, yyyy HH:mm:ss z")
 java.util.Calendar getCalendar()
          Gets a GregorianCalendar calendar instance
 java.util.Calendar getCalendar(java.util.TimeZone tz)
          Gets a GregorianCalendar calendar instance
static long getCurrentDayNumber(java.util.TimeZone tz)
          Returns the current (today) day number
static long getCurrentTimeMillis()
          Returns the current Epoch time in milliseconds since January 1, 1970 00:00:00 GMT
static long getCurrentTimeSec()
          Returns the current Epoch time in seconds since January 1, 1970 00:00:00 GMT
 java.util.Date getDate()
          Gets a Date object based on the time in this DateTime object
static DateTime.ParsedDateTime getDateFromDayNumber(long dayNumber)
          Returns the year/month/day from the day number (days since October 15, 1582)
static DateTime.ParsedDateTime getDateFromDayNumber(long dayNumber, java.util.TimeZone tmz)
          Returns the year/month/day from the day number (days since October 15, 1582)
static char[] GetDateSeparatorChars(java.lang.String dateFormat)
          Analyzes the specified date format to determine the date separator characters
static DateTime.DateStringFormat getDateStringFormat(java.lang.String dsfStr)
          Returns the defined DateStringFormat for the specified account.
 long getDayEnd()
          Returns an Epoch time in seconds which is the end of the day represented by this instance.
 long getDayEnd(java.util.TimeZone tz)
          Returns an Epoch time in seconds which is the end of the day represented by this instance.
 long getDayEndGMT()
          Returns the Epoch timestamp representing the end of the current day represented by this DateTime instance, based on the GMT TimeZone.
static int getDayIndex(java.lang.String day, int dft)
          Gets the day-of-week number for the specified day short abbreviation
static java.lang.String getDayName(int day, boolean abbrev)
          Gets the day-of-week name for the specified day number/index
static java.lang.String getDayName(int day, int abbrev)
          Gets the day-of-week name for the specified day number/index
static java.util.Map<java.lang.String,java.lang.Integer> getDayNameMap(boolean abbrev)
          Returns a Map object of day-of-week names to their 0-based number/index (used as a VComboBox item list)
static java.util.Map<java.lang.String,java.lang.Integer> getDayNameMap(int abbrev)
          Returns a Map object of day-of-week names to their 0-based number/index (used as a VComboBox item list)
static java.lang.String[] getDayNames(boolean abbrev)
          Returns an array of day-of-week names
static java.lang.String[] getDayNames(int abbrev)
          Returns an array of day-of-week names
 long getDayNumber()
          Returns the DayNumber long, for this DateTime instance
 long getDayNumber(java.util.TimeZone tz)
          Returns the DayNumber long, for this DateTime instance
static long getDayNumberFromDate(DateTime.ParsedDateTime pdt)
          Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)
static long getDayNumberFromDate(DateTime dt)
          Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)
static long getDayNumberFromDate(DateTime dt, java.util.TimeZone tz)
          Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)
static long getDayNumberFromDate(int year, int month1, int day)
          Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)
 int getDayOfMonth()
          Gets the day of the month represented by this DateTime instance
 int getDayOfMonth(java.util.TimeZone tz)
          Gets the day of the month represented by this DateTime instance
 int getDayOfWeek()
          Returns the day of week for this DateTime instance
static int getDayOfWeek(int year, int mon1, int day)
          Returns the day of the week for the specified year/month/day
 int getDayOfWeek(java.util.TimeZone tz)
          Returns the day of week for this DateTime instance
static int getDayOfYear(int year, int mon1, int day)
          Returns the day of the year for the specified year/month/day
 int getDaysInMonth()
          Gets the number of days in the month represented by this DateTime instance
 int getDaysInMonth(java.util.TimeZone tz)
          Gets the number of days in the month represented by this DateTime instance
static int getDaysInMonth(java.util.TimeZone tz, int mon1, int year)
          Gets the number of days in the specified month
 long getDayStart()
          Returns an Epoch time in seconds which is the beginning of the day represented by this instance.
 long getDayStart(java.util.TimeZone tz)
          Returns an Epoch time in seconds which is the beginning of the day represented by this instance.
 long getDayStartGMT()
          Returns the Epoch timestamp representing the start of the current day represented by this DateTime instance, based on the GMT TimeZone.
static java.util.TimeZone getDefaultTimeZone()
          Returns the default TimeZone
static java.util.TimeZone getGMTTimeZone()
          Returns the GMT TimeZone
 int getHour12()
          Returns the hour of the day (12-hour clock)
 int getHour12(java.util.TimeZone tz)
          Returns the hour of the day (12-hour clock)
 int getHour24()
          Returns the hour of the day (24-hour clock)
 int getHour24(java.util.TimeZone tz)
          Returns the hour of the day (24-hour clock)
static java.lang.String[] getHours(boolean hr24)
          Gets a String array of hours in a day (used as a VComboBox item list)
static DateTime getMaxDate()
          Gets the maximum acceptable DateTime
static DateTime getMaxDate(java.util.TimeZone tz)
          Gets the maximum acceptable DateTime
static int getMaxMonthDayCount(int mon1, boolean isLeapYear)
          Gets the maximum number of days in the specified month
static DateTime getMinDate()
          Gets the minimum acceptable DateTime
static DateTime getMinDate(java.util.TimeZone tz)
          Gets the minimum acceptable DateTime
 int getMinute()
          Returns the minute of the hour
 int getMinute(java.util.TimeZone tz)
          Returns the minute of the hour
 int getMinuteOfDay()
          Returns the minute of the current day
 int getMinuteOfDay(java.util.TimeZone tz)
          Returns the minute of the current day
static java.lang.String[] getMinutes()
          Gets a String array of minutes in a day (used as a VComboBox item list)
 int getMonth0()
          Gets the 0-based index of the month represented by this DateTime instance
 int getMonth0(java.util.TimeZone tz)
          Gets the 0-based index of the month represented by this DateTime instance
 int getMonth1()
          Gets the 1-based index of the month represented by this DateTime instance
 int getMonth1(java.util.TimeZone tz)
          Gets the 1-based index of the month represented by this DateTime instance
 long getMonthDelta(java.util.TimeZone tz, int deltaMo)
          Returns the Epoch timestamp representing the current date, plus the number of months offset.
 long getMonthEnd()
          Returns the Epoch timestamp representing the end of the month represented by this DateTime instance.
 long getMonthEnd(int deltaMo)
          Returns the Epoch timestamp representing the end of the month represented by this DateTime instance, plus the specified delta month offset.
 long getMonthEnd(java.util.TimeZone tz)
          Returns the Epoch timestamp representing the end of the month represented by this DateTime instance.
 long getMonthEnd(java.util.TimeZone tz, int deltaMo)
          Returns the Epoch timestamp representing the end of the month represented by this DateTime instance, plus the specified delta month offset.
static int getMonthIndex0(java.lang.String month, int dft)
          Gets the 0-based index for the specified month abbreviation
static int getMonthIndex1(java.lang.String month, int dft)
          Gets the 1-based index for the specified month abbreviation
static java.lang.String getMonthName(int mon1, boolean abbrev)
          Gets the month name/abbreviation for the specified 1-based month index
static java.util.Map<java.lang.String,java.lang.Integer> getMonthNameMap(boolean abbrev)
          Returns a Map object containing a map of month names/abbreviations and it's 0-based month index [0..11]
static java.lang.String[] getMonthNames(boolean abbrev)
          Returns all month names/appreviations
 long getMonthStart()
          Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance.
 long getMonthStart(int deltaMo)
          Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance, plus the specified delta month offset.
 long getMonthStart(java.util.TimeZone tz)
          Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance.
 long getMonthStart(java.util.TimeZone tz, int deltaMo)
          Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance, plus the specified delta month offset.
 int getSecond()
          Returns the second of the minute
 int getSecond(java.util.TimeZone tz)
          Returns the second of the minute
 int getSecondOfDay()
          Returns the second of the current day
 int getSecondOfDay(java.util.TimeZone tz)
          Returns the second of the current day (Time of day)
 long getTimeMillis()
          Gets the Epoch time in milliseconds represented by this instance
 long getTimeSec()
          Gets the Epoch time in seconds represented by this instance
 java.util.TimeZone getTimeZone()
          Returns the default (or current) TimeZone
static java.util.TimeZone getTimeZone(java.lang.String tzid)
          Gets the TimeZone instance for the specified TimeZone id
static java.util.TimeZone getTimeZone(java.lang.String tzid, java.util.TimeZone dft)
          Gets the TimeZone instance for the specified TimeZone id
 java.lang.String getTimeZoneID()
          Returns the ID of the current TimeZone
 java.lang.String getTimeZoneShortName()
          Returns the short-name of the current TimeZone
 int getYear()
          Returns the year for this DataTime instance
 int getYear(java.util.TimeZone tz)
          Returns the year for this DataTime instance
 double getYearsSince(DateTime priorDate)
          Return the number of years since specified date (year/month/day).
 double getYearsSince(DateTime priorDate, java.util.TimeZone tz)
          Return the number of years since specified date (year/month/day).
 double getYearsSince(int year, int month1, int day)
          Return the number of years since specified date (year/month/day).
 double getYearsSince(long priorDayNumber)
          Return the number of years since specified date (year/month/day).
 double getYearsSince(long priorDayNumber, java.util.TimeZone tz)
          Return the number of years since specified date (year/month/day).
 java.lang.String gmtFormat()
          Formats the current DateTime instance (using format "yyyy/MM/dd HH:mm:ss 'GMT'"), based on the GMT TimeZone.
 java.lang.String gmtFormat(java.lang.String fmt)
          Formats the current DateTime instance, based on the GMT TimeZone.
 java.lang.String gmtFormat(java.lang.String fmt, java.lang.StringBuffer sb)
          Formats the current DateTime instance, based on the GMT TimeZone.
static long HourSeconds(long hours)
          Returns the number of seconds in the specified number of hours
 boolean isAfter(DateTime dt)
          Returns true if the this DateTime is after the specified DateTime instance
 boolean isAfter(DateTime dt, boolean inclusive)
          Returns true if the this DateTime is after the specified DateTime instance
 boolean isAM()
          Returns true if AM, false if PM
 boolean isAM(java.util.TimeZone tz)
          Returns true if AM, false if PM
 boolean isBefore(DateTime dt)
          Returns true if this DateTime is before the specified DateTime instance
 boolean isBefore(DateTime dt, boolean inclusive)
          Returns true if this DateTime is before the specified DateTime instance
 boolean isDaylightSavings()
          Returns true if this DateTime instance currently represents a daylight savings time.
 boolean isDaylightSavings(java.util.TimeZone tz)
          Returns true if this DateTime instance currently represents a daylight savings time.
 boolean isFuture(long deltaSec)
          Returns true if the this DateTime is more than the specified seconds into the future.
 boolean isLeapYear()
          Returns true if this DateTime instance represents a leap-year
static boolean isLeapYear(int year)
          Returns true if the specified year represents a leap-year
 boolean isLeapYear(java.util.TimeZone tz)
          Returns true if this DateTime instance represents a leap-year
 boolean isPM()
          Returns true if PM, false if AM
 boolean isPM(java.util.TimeZone tz)
          Returns true if PM, false if AM
static boolean isRecentSec(long timeSec, long lapseSec)
          Returns true if the specified time is within the specified lapsed time
static boolean isValid(DateTime dt)
          Returns true if the specified date is valid
static boolean isValidTimeZone(java.lang.String tzid)
          Returns true if the specified TimeZone is valid
static void main(java.lang.String[] argv)
          Main entry point for testing/debugging
static long MinuteSeconds(long minutes)
          Returns the number of seconds in the specified number of minutes
static DateTime parseArgumentDate(java.lang.String dateStr)
          Parse specified String into a DateTime instance.
static DateTime parseArgumentDate(java.lang.String dateStr, java.util.TimeZone dftTZ)
          Parse specified String into a DateTime instance.
static DateTime parseArgumentDate(java.lang.String dateStr, java.util.TimeZone dftTZ, boolean isToDate)
          Parse specified String into a DateTime instance.
static DateTime parseArgumentDate(java.lang.String dateStr, java.util.TimeZone dftTZ, DateTime.DefaultParsedTime dftTime)
          Parse specified String into a DateTime instance.
static DateTime.ParsedDateTime parseDateTime(java.lang.String dateStr, java.util.TimeZone dftTZ, DateTime.DefaultParsedTime dftTime)
          Parse specified String into a ParsedDateTime instance.
static int parseHourMinuteSecond(java.lang.String hms)
          Parses the specified "hhhh:mm:ss" String into the number of represented seconds
static int parseHourMinuteSecond(java.lang.String hms, int dft)
          Parses the specified "hhhh:mm:ss" String into the number of represented seconds
static java.lang.String[] readTimeZones(java.io.File tmzFile)
          Reads the available TimeZone IDs from the specified file.
 void setDate(java.lang.String d)
          Sets the current time of this instance
 void setDate(java.lang.String d, java.util.TimeZone dftTMZ)
          Sets the current time of this instance
 void setDate(java.util.TimeZone tz, int year, int month1, int day)
          Sets the current date of this instance (time is left unchanged)
 void setDate(java.util.TimeZone tz, int year, int month1, int day, int hour24, int minute, int second)
          Sets the current time of this instance
 void setTimeMillis(long timeMillis)
          Sets the Epoch time in milliseconds represented by this instance
 void setTimeSec(long timeSec)
          Sets the Epoch time in seconds represented by this instance
 void setTimeZone(java.lang.String tz)
          Sets the current TimeZone
 void setTimeZone(java.util.TimeZone tz)
          Sets the current TimeZone
 java.lang.String shortFormat(java.util.TimeZone tz)
          Formats the current DateTime instance (using format "MMM dd, yyyy HH:mm:ss z")
 java.lang.String toString()
          Returns a String representation of this DateTime instance
static java.lang.String toString(long timeSec)
          Returns a String representation of the specified epoch time seconds
 java.lang.String toString(java.util.TimeZone tmz)
          Returns a String representation of this DateTime instance
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GMT_TIMEZONE

public static final java.lang.String GMT_TIMEZONE
See Also:
Constant Field Values

GMT

public static final java.util.TimeZone GMT

LOWERCASE_TIMEZONE_LOOKUP

public static final boolean LOWERCASE_TIMEZONE_LOOKUP
See Also:
Constant Field Values

DEFAULT_DATE_FORMAT

public static final java.lang.String DEFAULT_DATE_FORMAT
See Also:
Constant Field Values

DEFAULT_TIME_FORMAT

public static final java.lang.String DEFAULT_TIME_FORMAT
See Also:
Constant Field Values

DEFAULT_TIMEZONE_FORMAT

public static final java.lang.String DEFAULT_TIMEZONE_FORMAT
See Also:
Constant Field Values

ISO8601_DATETIME_FORMAT

public static final java.lang.String ISO8601_DATETIME_FORMAT
See Also:
Constant Field Values

DEFAULT_DATETIME_FORMAT

public static final java.lang.String DEFAULT_DATETIME_FORMAT
See Also:
Constant Field Values

DEFAULT_DATETIME_TZ_FORMAT

public static final java.lang.String DEFAULT_DATETIME_TZ_FORMAT
See Also:
Constant Field Values

INVALID_DATETIME

public static final DateTime INVALID_DATETIME

MIN_DATETIME

public static final DateTime MIN_DATETIME

MAX_DATETIME

public static final DateTime MAX_DATETIME

MIN_TIMESEC

public static final long MIN_TIMESEC

MAX_TIMESEC

public static final long MAX_TIMESEC

HOURS_PER_DAY

public static final long HOURS_PER_DAY
See Also:
Constant Field Values

SECONDS_PER_MINUTE

public static final long SECONDS_PER_MINUTE
See Also:
Constant Field Values

MINUTES_PER_HOUR

public static final long MINUTES_PER_HOUR
See Also:
Constant Field Values

DAYS_PER_WEEK

public static final long DAYS_PER_WEEK
See Also:
Constant Field Values

SECONDS_PER_HOUR

public static final long SECONDS_PER_HOUR
See Also:
Constant Field Values

MINUTES_PER_DAY

public static final long MINUTES_PER_DAY
See Also:
Constant Field Values

SECONDS_PER_DAY

public static final long SECONDS_PER_DAY
See Also:
Constant Field Values

MINUTES_PER_WEEK

public static final long MINUTES_PER_WEEK
See Also:
Constant Field Values

SECONDS_PER_WEEK

public static final long SECONDS_PER_WEEK
See Also:
Constant Field Values

MINUTES_PER_SECOND

public static final double MINUTES_PER_SECOND
See Also:
Constant Field Values

HOURS_PER_MINUTE

public static final double HOURS_PER_MINUTE
See Also:
Constant Field Values

HOURS_PER_SECOND

public static final double HOURS_PER_SECOND
See Also:
Constant Field Values

MONTHS_PER_YEAR

public static final int MONTHS_PER_YEAR
See Also:
Constant Field Values

JAN

public static final int JAN
See Also:
Constant Field Values

FEB

public static final int FEB
See Also:
Constant Field Values

MAR

public static final int MAR
See Also:
Constant Field Values

APR

public static final int APR
See Also:
Constant Field Values

MAY

public static final int MAY
See Also:
Constant Field Values

JUN

public static final int JUN
See Also:
Constant Field Values

JUL

public static final int JUL
See Also:
Constant Field Values

AUG

public static final int AUG
See Also:
Constant Field Values

SEP

public static final int SEP
See Also:
Constant Field Values

OCT

public static final int OCT
See Also:
Constant Field Values

NOV

public static final int NOV
See Also:
Constant Field Values

DEC

public static final int DEC
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

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

SUN

public static final int SUN
See Also:
Constant Field Values

MON

public static final int MON
See Also:
Constant Field Values

TUE

public static final int TUE
See Also:
Constant Field Values

WED

public static final int WED
See Also:
Constant Field Values

THU

public static final int THU
See Also:
Constant Field Values

FRI

public static final int FRI
See Also:
Constant Field Values

SAT

public static final int SAT
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
Constructor Detail

DateTime

public DateTime()
Default constructor. Initialize with the current Epoch time.


DateTime

public DateTime(java.util.TimeZone tz)
Constructor. Initialize with the current Epoch time.

Parameters:
tz - The TimeZone

DateTime

public DateTime(java.util.Date date)
Constructor.

Parameters:
date - The Date object used to initialize this DateTime

DateTime

public DateTime(java.util.Date date,
                java.util.TimeZone tz)
Constructor.

Parameters:
date - The Date object used to initialize this DateTime
tz - The TimeZone

DateTime

public DateTime(java.util.TimeZone tz,
                int year,
                int month1,
                int day)
Constructor (time is set to Noon)

Parameters:
tz - The TimeZone
year - The year
month1 - The 1-based month index [1..12]
day - The day

DateTime

public DateTime(java.util.TimeZone tz,
                int year,
                int month1,
                int day,
                int hour24,
                int minute,
                int second)
Constructor.

Parameters:
tz - The TimeZone
year - The year
month1 - The 1-based month index [1..12]
day - The day
hour24 - The hour of the day [24 hour clock]
minute - The minute of the hour
second - The second of the minute

DateTime

public DateTime(long timeSec)
Constructor.

Parameters:
timeSec - The Epoch time in seconds

DateTime

public DateTime(long timeSec,
                java.util.TimeZone tz)
Constructor.

Parameters:
timeSec - The Epoch time in seconds
tz - The TimeZone

DateTime

public DateTime(java.lang.String d)
         throws DateTime.DateParseException
Constructor.

Parameters:
d - A date/time String representation
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

DateTime

public DateTime(DateTime dt)
Copy constructor

Parameters:
dt - Another DateTime instance

DateTime

public DateTime(DateTime dt,
                long deltaOffsetSec)
Copy constructor with delta offset time

Parameters:
dt - Another DateTime instance
deltaOffsetSec - +/- offset from time specified in DateTime instance
Method Detail

CompactDateTimeFormat

public static java.lang.String CompactDateTimeFormat(java.lang.String sep)
Returns a compact date/time format
This format can be parsed by the "parseArgumentDate" method if the specified separator is one of ",", " ", or "|".

Parameters:
sep - The date|time|zone separator String.
Returns:
The date|time|zone format string

CompactDateTimeFormat

public static java.lang.String CompactDateTimeFormat(char sep)
Returns a compact date/time format
This format can be parsed by the "parseArgumentDate" method if the specified separator is one of ",", " ", or "|".

Parameters:
sep - The date|time|zone separator character.
Returns:
The date|time|zone format string

GetDateSeparatorChars

public static char[] GetDateSeparatorChars(java.lang.String dateFormat)
Analyzes the specified date format to determine the date separator characters

Parameters:
dateFormat - The date format to analyze
Returns:
The date separator characters

getDateStringFormat

public static DateTime.DateStringFormat getDateStringFormat(java.lang.String dsfStr)
Returns the defined DateStringFormat for the specified account.

Parameters:
dsfStr - The String value of the format (ie. "YMD", "MDY", "DMY")
Returns:
The DateStringFormat

DaySeconds

public static long DaySeconds(long days)
Returns the number of seconds in the specified number of days

Parameters:
days - The number of days to convert to seconds
Returns:
The number of seconds

DaySeconds

public static long DaySeconds(double days)
Returns the number of seconds in the specified number of days

Parameters:
days - The number of days to convert to seconds
Returns:
The number of seconds

HourSeconds

public static long HourSeconds(long hours)
Returns the number of seconds in the specified number of hours

Parameters:
hours - The number of hours to convert to seconds
Returns:
The number of seconds

MinuteSeconds

public static long MinuteSeconds(long minutes)
Returns the number of seconds in the specified number of minutes

Parameters:
minutes - The number of minutes to convert to seconds
Returns:
The number of seconds

getMonthIndex0

public static int getMonthIndex0(java.lang.String month,
                                 int dft)
Gets the 0-based index for the specified month abbreviation

Parameters:
month - The month abbreviation
Returns:
The 0-based index [0..11] of the specified month appreviation

getMonthIndex1

public static int getMonthIndex1(java.lang.String month,
                                 int dft)
Gets the 1-based index for the specified month abbreviation

Parameters:
month - The month abbreviation
Returns:
The 1-based index [1..12] of the specified month appreviation

getMonthName

public static java.lang.String getMonthName(int mon1,
                                            boolean abbrev)
Gets the month name/abbreviation for the specified 1-based month index

Parameters:
mon1 - A 1-based month index [1..12]
abbrev - True to return the month abbreviation, false to return the name
Returns:
The month name/abbreviation

getMonthNames

public static java.lang.String[] getMonthNames(boolean abbrev)
Returns all month names/appreviations

Parameters:
abbrev - True to return month abbreviations, false to return month names
Returns:
An array of month names/abbreviations

getMonthNameMap

public static java.util.Map<java.lang.String,java.lang.Integer> getMonthNameMap(boolean abbrev)
Returns a Map object containing a map of month names/abbreviations and it's 0-based month index [0..11]

Parameters:
abbrev - True to create the Map object with abbreviations, false for names
Returns:
The Map object

getDaysInMonth

public static int getDaysInMonth(java.util.TimeZone tz,
                                 int mon1,
                                 int year)
Gets the number of days in the specified month

Parameters:
tz - The TimeZone
mon1 - The 1-based month index [1..12]
year - The year [valid for all AD years]
Returns:
The number of days in the specified month

getMaxMonthDayCount

public static int getMaxMonthDayCount(int mon1,
                                      boolean isLeapYear)
Gets the maximum number of days in the specified month

Parameters:
mon1 - The 1-based month index [1..12]
isLeapYear - True for leap-year, false otherwise
Returns:
The maximum number of days in the specified month

isLeapYear

public static boolean isLeapYear(int year)
Returns true if the specified year represents a leap-year

Parameters:
year - The year [valid for all AD years]
Returns:
True if the year is a leap-year, false otherwise

getDayIndex

public static int getDayIndex(java.lang.String day,
                              int dft)
Gets the day-of-week number for the specified day short abbreviation

Parameters:
day - The day short abbreviation
Returns:
The 0-based day index [0..6]

getDayName

public static java.lang.String getDayName(int day,
                                          int abbrev)
Gets the day-of-week name for the specified day number/index

Parameters:
day - A 0-based day number/index [0..6]
abbrev - 0 for full name, 1 for abbreviation, 2 for short abbreviation
Returns:
The day-of-week name/abbreviation

getDayName

public static java.lang.String getDayName(int day,
                                          boolean abbrev)
Gets the day-of-week name for the specified day number/index

Parameters:
day - A 0-based day number/index [0..6]
abbrev - True for abbreviation, false for full name
Returns:
The day-of-week name/abbreviation

getDayNames

public static java.lang.String[] getDayNames(int abbrev)
Returns an array of day-of-week names

Parameters:
abbrev - 0 for full name, 1 for abbreviation, 2 for short abbreviation
Returns:
An array of day-of-week names/abbreviations

getDayNames

public static java.lang.String[] getDayNames(boolean abbrev)
Returns an array of day-of-week names

Parameters:
abbrev - True abbreviations, false for full names
Returns:
An array of day-of-week names/abbreviations

getDayNameMap

public static java.util.Map<java.lang.String,java.lang.Integer> getDayNameMap(int abbrev)
Returns a Map object of day-of-week names to their 0-based number/index (used as a VComboBox item list)

Parameters:
abbrev - 0 for full name, 1 for abbreviation, 2 for short abbreviation
Returns:
The Map object

getDayNameMap

public static java.util.Map<java.lang.String,java.lang.Integer> getDayNameMap(boolean abbrev)
Returns a Map object of day-of-week names to their 0-based number/index (used as a VComboBox item list)

Parameters:
abbrev - True for abbreviations, false for full names
Returns:
The Map object

getDayOfWeek

public static int getDayOfWeek(int year,
                               int mon1,
                               int day)
Returns the day of the week for the specified year/month/day

Parameters:
year - The year [valid for dates after 1582/10/15]
mon1 - The month [1..12]
day - The day [1..31]
Returns:
The day of the week (0=Sunday, 6=Saturday)

getDayOfYear

public static int getDayOfYear(int year,
                               int mon1,
                               int day)
Returns the day of the year for the specified year/month/day

Parameters:
year - The year [valid for dates after 1582/10/15]
mon1 - The month [1..12]
day - The day [1..31]
Returns:
The day of the year

getHours

public static java.lang.String[] getHours(boolean hr24)
Gets a String array of hours in a day (used as a VComboBox item list)

Parameters:
hr24 - True for 24 hour clock, false for 12 hour clock
Returns:
A String array of hours in a day

getMinutes

public static java.lang.String[] getMinutes()
Gets a String array of minutes in a day (used as a VComboBox item list)

Returns:
A String array of minutes in a day

toString

public static java.lang.String toString(long timeSec)
Returns a String representation of the specified epoch time seconds

Parameters:
timeSec - The Epoch time seconds
Returns:
The String representation

getCurrentTimeSec

public static long getCurrentTimeSec()
Returns the current Epoch time in seconds since January 1, 1970 00:00:00 GMT

Returns:
The current Epoch time in seconds

getCurrentTimeMillis

public static long getCurrentTimeMillis()
Returns the current Epoch time in milliseconds since January 1, 1970 00:00:00 GMT

Returns:
The current Epoch time in milliseconds

isRecentSec

public static boolean isRecentSec(long timeSec,
                                  long lapseSec)
Returns true if the specified time is within the specified lapsed time

Parameters:
timeSec - An Epoch time in seconds
lapseSec - The time duration to test
Returns:
True if the specified time is within the specified lapsed time

isValid

public static boolean isValid(DateTime dt)
Returns true if the specified date is valid

Parameters:
dt - The DateTime to check
Returns:
True if the specified date is valid

getMinDate

public static DateTime getMinDate()
Gets the minimum acceptable DateTime

Returns:
The minimum acceptable DateTime

getMinDate

public static DateTime getMinDate(java.util.TimeZone tz)
Gets the minimum acceptable DateTime

Parameters:
tz - The TimeZone (not that it really matters)
Returns:
The minimum acceptable DateTime

getMaxDate

public static DateTime getMaxDate()
Gets the maximum acceptable DateTime

Returns:
The maximum acceptable DateTime

getMaxDate

public static DateTime getMaxDate(java.util.TimeZone tz)
Gets the maximum acceptable DateTime

Parameters:
tz - The TimeZone (not that it really matters)
Returns:
The maximum acceptable DateTime

parseDateTime

public static DateTime.ParsedDateTime parseDateTime(java.lang.String dateStr,
                                                    java.util.TimeZone dftTZ,
                                                    DateTime.DefaultParsedTime dftTime)
                                             throws DateTime.DateParseException
Parse specified String into a ParsedDateTime instance. This method parses a date which has been provided as an argument to a command-line tool or in a URL request string. Allowable Date Formats:
YYYY-MM-DDThh:mm:ssZ (ie. "2012-03-08T06:49:58Z" ISO-8601 - GPX date format)
YYYY-MM-DDThh:mm:ss+XX:XX (ie. "2012-03-08T06:49:58+00:00")
YYYY/MM[/DD[/hh[:mm[:ss]]]][,ZZZ] (ie. "2010/07/04/12:57:32,PST")
YYYY/MM/DD,hh[:mm[:ss]]]][,ZZZ] (ie. "2010/07/04,12:57:32,PST")
EEEEEEEE[,ZZZ] (ie. "1277704868,PST")
-Dh[,ZZZ] (ie. "-5h,PST" => "5 hours ago")
-Dd[,hh[:mm[:ss]]][,ZZZ] (ie. "-3d,PST" => "3 days ago")
+Dd[,hh[:mm[:ss]]][,ZZZ] (ie. "+4d,PST" => "4 days from now")
-Dm[,hh[:mm[:ss]]][,ZZZ] (ie. "-2m,PST" => "2 months ago")
+Dm[,hh[:mm[:ss]]][,ZZZ] (ie. "+3m,PST" => "3 months from now")
-Dy[,hh[:mm[:ss]]][,ZZZ] (ie. "-1y,PST" => "1 year ago")
+Dy[,hh[:mm[:ss]]][,ZZZ] (ie. "+5y,PST" => "5 years from now")
Examples: "2010/07/04/12:57:32,PST" "2010/07/04,12:57,EST" "2010/07/04|12:57|EST" "1277704868,PST" "-0d" (today) "-1d,PST" (yesterday) "-3d,WST" (3 days ago) "+4d,CST" (4 days from now) "-1m" (last month) "-0m" (this month) "+1m" (next month) "-Sun,MST" (last Sunday) "+WED,PST" (next Wednesday) "-1y" (last year) "-0y" (this year) "+1y" (next year)

Parameters:
dateStr - The date String to parse
dftTZ - The default TimeZone
dftTime - Enum indicating what 'time' to use if a time is not specified
Returns:
The parsed ParsedDateTime instance, or null if unable to parse the specified date/time string
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

parseArgumentDate

public static DateTime parseArgumentDate(java.lang.String dateStr,
                                         java.util.TimeZone dftTZ,
                                         DateTime.DefaultParsedTime dftTime)
                                  throws DateTime.DateParseException
Parse specified String into a DateTime instance. This method parses a date which has been provided as an argument to a command-line tool or in a URL request string.
(see "parseDateTime" for allowable Date Formats)

Parameters:
dateStr - The date String to parse
dftTZ - The default TimeZone
dftTime - Enum indicating what 'time' to use if a time is not specified
Returns:
The parsed DateTime instance
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

parseArgumentDate

public static DateTime parseArgumentDate(java.lang.String dateStr,
                                         java.util.TimeZone dftTZ,
                                         boolean isToDate)
                                  throws DateTime.DateParseException
Parse specified String into a DateTime instance. This method parses a date which has been provided as an argument to a command-line tool or in a URL request string.
(see "parseDateTime" for allowable Date Formats)

Parameters:
dateStr - The date String to parse
dftTZ - The default TimeZone
isToDate - True to default to an end-of-day time if the time is not specified
Returns:
The parsed DateTime instance
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

parseArgumentDate

public static DateTime parseArgumentDate(java.lang.String dateStr,
                                         java.util.TimeZone dftTZ)
                                  throws DateTime.DateParseException
Parse specified String into a DateTime instance. This method parses a date which has been provided as an argument to a command-line tool or in a URL request string. (see "parseDateTime" for allowable Date Formats)

Parameters:
dateStr - The date String to parse
dftTZ - The default TimeZone
Returns:
The parsed DateTime instance
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

parseArgumentDate

public static DateTime parseArgumentDate(java.lang.String dateStr)
                                  throws DateTime.DateParseException
Parse specified String into a DateTime instance. This method parses a date which has been provided as an argument to a command-line tool or in a URL request string. (see "parseDateTime" for allowable Date Formats)

Parameters:
dateStr - The date String to parse
Returns:
The parsed DateTime instance
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

getDayNumberFromDate

public static long getDayNumberFromDate(int year,
                                        int month1,
                                        int day)
Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)

Parameters:
year - The year [1582..4000]
month1 - The month [1..12]
day - The day [1..31]
Returns:
The number of days since October 15, 1582.

getDayNumberFromDate

public static long getDayNumberFromDate(DateTime.ParsedDateTime pdt)
Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)


getDayNumberFromDate

public static long getDayNumberFromDate(DateTime dt,
                                        java.util.TimeZone tz)
Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)


getDayNumberFromDate

public static long getDayNumberFromDate(DateTime dt)
Returns the day number of days since October 15, 1582 (the first day of the Gregorian Calendar)


getCurrentDayNumber

public static long getCurrentDayNumber(java.util.TimeZone tz)
Returns the current (today) day number

Parameters:
tz - The current timezone
Returns:
The current day number

getDateFromDayNumber

public static DateTime.ParsedDateTime getDateFromDayNumber(long dayNumber)
Returns the year/month/day from the day number (days since October 15, 1582)

Parameters:
dayNumber - The number of days since October 15, 1582
Returns:
ParsedDateTime structure containing the year/month/day.

getDateFromDayNumber

public static DateTime.ParsedDateTime getDateFromDayNumber(long dayNumber,
                                                           java.util.TimeZone tmz)
Returns the year/month/day from the day number (days since October 15, 1582)

Parameters:
dayNumber - The number of days since October 15, 1582
Returns:
ParsedDateTime structure containing the year/month/day.

getDate

public java.util.Date getDate()
Gets a Date object based on the time in this DateTime object

Returns:
A Date instance

setDate

public void setDate(java.util.TimeZone tz,
                    int year,
                    int month1,
                    int day)
Sets the current date of this instance (time is left unchanged)

Parameters:
tz - The TimeZone
year - The year
month1 - The 1-based month index [1..12]
day - The day

setDate

public void setDate(java.util.TimeZone tz,
                    int year,
                    int month1,
                    int day,
                    int hour24,
                    int minute,
                    int second)
Sets the current time of this instance

Parameters:
tz - The TimeZone
year - The year (1970+)
month1 - The 1-based month index [1..12]
day - The day of the month
hour24 - The hour of the day [24 hour clock]
minute - The minute of the hour
second - The second of the minute

setDate

public void setDate(java.lang.String d)
             throws DateTime.DateParseException
Sets the current time of this instance

Parameters:
d - The String representation of a date/time
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

setDate

public void setDate(java.lang.String d,
                    java.util.TimeZone dftTMZ)
             throws DateTime.DateParseException
Sets the current time of this instance

Parameters:
d - The String representation of a date/time
dftTMZ - The TimeZone used if no timezone was parsed from the String
Throws:
DateTime.DateParseException - if an invalid date/time format was specified.

getCalendar

public java.util.Calendar getCalendar(java.util.TimeZone tz)
Gets a GregorianCalendar calendar instance

Parameters:
tz - The TimeZone
Returns:
The Calendar object

getCalendar

public java.util.Calendar getCalendar()
Gets a GregorianCalendar calendar instance

Returns:
The Calendar object

getMonth0

public int getMonth0(java.util.TimeZone tz)
Gets the 0-based index of the month represented by this DateTime instance

Parameters:
tz - The TimeZone used when calculating the 0-based month index
Returns:
The 0-based month index

getMonth0

public int getMonth0()
Gets the 0-based index of the month represented by this DateTime instance

Returns:
The 0-based month index

getMonth1

public int getMonth1(java.util.TimeZone tz)
Gets the 1-based index of the month represented by this DateTime instance

Parameters:
tz - The TimeZone used when calculating the 0-based month index
Returns:
The 1-based month index

getMonth1

public int getMonth1()
Gets the 1-based index of the month represented by this DateTime instance

Returns:
The 1-based month index

getDayOfMonth

public int getDayOfMonth(java.util.TimeZone tz)
Gets the day of the month represented by this DateTime instance

Parameters:
tz - The TimeZone used when calculating the day of the month
Returns:
The day of the month

getDayOfMonth

public int getDayOfMonth()
Gets the day of the month represented by this DateTime instance

Returns:
The day of the month

getDaysInMonth

public int getDaysInMonth(java.util.TimeZone tz)
Gets the number of days in the month represented by this DateTime instance

Parameters:
tz - The TimeZone used when calculating the number of days in the month
Returns:
The number of days in the month

getDaysInMonth

public int getDaysInMonth()
Gets the number of days in the month represented by this DateTime instance

Returns:
The number of days in the month

getDayOfWeek

public int getDayOfWeek(java.util.TimeZone tz)
Returns the day of week for this DateTime instance

Parameters:
tz - The TimeZone used when calculating the day of week
Returns:
The day of week (0=Sunday ... 6=Saturday)

getDayOfWeek

public int getDayOfWeek()
Returns the day of week for this DateTime instance

Returns:
The day of week (0=Sunday ... 6=Saturday)

getYear

public int getYear(java.util.TimeZone tz)
Returns the year for this DataTime instance

Parameters:
tz - The TimeZone used when calculating the year
Returns:
The year.

getYear

public int getYear()
Returns the year for this DataTime instance

Returns:
The year.

isLeapYear

public boolean isLeapYear(java.util.TimeZone tz)
Returns true if this DateTime instance represents a leap-year

Parameters:
tz - The TimeZone used when calculating the leap-year
Returns:
True if the year is a leap-year, false otherwise

isLeapYear

public boolean isLeapYear()
Returns true if this DateTime instance represents a leap-year

Returns:
True if the year is a leap-year, false otherwise

getHour24

public int getHour24(java.util.TimeZone tz)
Returns the hour of the day (24-hour clock)

Parameters:
tz - The TimeZone used when calculating the hour of the day
Returns:
The hour of the day

getHour24

public int getHour24()
Returns the hour of the day (24-hour clock)

Returns:
The hour of the day

getHour12

public int getHour12(java.util.TimeZone tz)
Returns the hour of the day (12-hour clock)

Parameters:
tz - The TimeZone used when calculating the hour of the day
Returns:
The hour of the day

getHour12

public int getHour12()
Returns the hour of the day (12-hour clock)

Returns:
The hour of the day

isAM

public boolean isAM(java.util.TimeZone tz)
Returns true if AM, false if PM

Parameters:
tz - The TimeZone used when calculating AM/PM
Returns:
True if AM, false if PM

isAM

public boolean isAM()
Returns true if AM, false if PM

Returns:
True if AM, false if PM

isPM

public boolean isPM(java.util.TimeZone tz)
Returns true if PM, false if AM

Parameters:
tz - The TimeZone used when calculating AM/PM
Returns:
True if PM, false if AM

isPM

public boolean isPM()
Returns true if PM, false if AM

Returns:
True if PM, false if AM

getMinute

public int getMinute(java.util.TimeZone tz)
Returns the minute of the hour

Parameters:
tz - The TimeZone used when calculating the minute
Returns:
The minute of the hour

getMinute

public int getMinute()
Returns the minute of the hour

Returns:
The minute of the hour

getMinuteOfDay

public int getMinuteOfDay(java.util.TimeZone tz)
Returns the minute of the current day

Parameters:
tz - The TimeZone used when calculating the minute
Returns:
The minute of the current day

getMinuteOfDay

public int getMinuteOfDay()
Returns the minute of the current day

Returns:
The minute of the current day

getSecond

public int getSecond(java.util.TimeZone tz)
Returns the second of the minute

Parameters:
tz - The TimeZone used when calculating the second
Returns:
The second of the minute

getSecond

public int getSecond()
Returns the second of the minute

Returns:
The second of the minute

getSecondOfDay

public int getSecondOfDay(java.util.TimeZone tz)
Returns the second of the current day (Time of day)

Parameters:
tz - The TimeZone used when calculating the second
Returns:
The second of the current day

getSecondOfDay

public int getSecondOfDay()
Returns the second of the current day

Returns:
The second of the current day

isDaylightSavings

public boolean isDaylightSavings(java.util.TimeZone tz)
Returns true if this DateTime instance currently represents a daylight savings time.

Parameters:
tz - The TimeZone used when calculating daylight savings time.
Returns:
True if this DateTime instance currently represents a daylight savings time.

isDaylightSavings

public boolean isDaylightSavings()
Returns true if this DateTime instance currently represents a daylight savings time.

Returns:
True if this DateTime instance currently represents a daylight savings time.

getDayNumber

public long getDayNumber(java.util.TimeZone tz)
Returns the DayNumber long, for this DateTime instance

Parameters:
tz - the Timezone
Returns:
The long day number

getDayNumber

public long getDayNumber()
Returns the DayNumber long, for this DateTime instance

Returns:
The long day number

getTimeSec

public long getTimeSec()
Gets the Epoch time in seconds represented by this instance

Returns:
The Epoch time in seconds

setTimeSec

public void setTimeSec(long timeSec)
Sets the Epoch time in seconds represented by this instance

Parameters:
timeSec - Epoch time in seconds

getTimeMillis

public long getTimeMillis()
Gets the Epoch time in milliseconds represented by this instance

Returns:
The Epoch time in milliseconds

setTimeMillis

public void setTimeMillis(long timeMillis)
Sets the Epoch time in milliseconds represented by this instance

Parameters:
timeMillis - Epoch time in milliseconds

getDayStart

public long getDayStart(java.util.TimeZone tz)
Returns an Epoch time in seconds which is the beginning of the day represented by this instance.

Parameters:
tz - The TimeZone
Returns:
An Epoch time which is at the beginning of the day represented by this instance.

getDayStart

public long getDayStart()
Returns an Epoch time in seconds which is the beginning of the day represented by this instance.

Returns:
An Epoch time which is at the beginning of the day represented by this instance.

getDayEnd

public long getDayEnd(java.util.TimeZone tz)
Returns an Epoch time in seconds which is the end of the day represented by this instance.

Parameters:
tz - The TimeZone
Returns:
An Epoch time which is at the end of the day represented by this instance.

getDayEnd

public long getDayEnd()
Returns an Epoch time in seconds which is the end of the day represented by this instance.

Returns:
An Epoch time which is at the end of the day represented by this instance.

getMonthStart

public long getMonthStart(java.util.TimeZone tz,
                          int deltaMo)
Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance, plus the specified delta month offset.

Parameters:
tz - The overriding TimeZone
deltaMo - The delta monnths (added to the month represented by this DateTime instance)
Returns:
The Epoch timestamp

getMonthStart

public long getMonthStart(java.util.TimeZone tz)
Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance.

Parameters:
tz - The overriding TimeZone
Returns:
The Epoch timestamp

getMonthStart

public long getMonthStart(int deltaMo)
Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance, plus the specified delta month offset.

Parameters:
deltaMo - The delta monnths (added to the month represented by this DateTime instance)
Returns:
The Epoch timestamp

getMonthStart

public long getMonthStart()
Returns the Epoch timestamp representing the beginning of the month represented by this DateTime instance.

Returns:
The Epoch timestamp

getMonthEnd

public long getMonthEnd(java.util.TimeZone tz,
                        int deltaMo)
Returns the Epoch timestamp representing the end of the month represented by this DateTime instance, plus the specified delta month offset.

Parameters:
tz - The overriding TimeZone
deltaMo - The delta monnths (added to the month represented by this DateTime instance)
Returns:
The Epoch timestamp

getMonthEnd

public long getMonthEnd(java.util.TimeZone tz)
Returns the Epoch timestamp representing the end of the month represented by this DateTime instance.

Parameters:
tz - The overriding TimeZone
Returns:
The Epoch timestamp

getMonthEnd

public long getMonthEnd(int deltaMo)
Returns the Epoch timestamp representing the end of the month represented by this DateTime instance, plus the specified delta month offset.

Parameters:
deltaMo - The delta monnths (added to the month represented by this DateTime instance)
Returns:
The Epoch timestamp

getMonthEnd

public long getMonthEnd()
Returns the Epoch timestamp representing the end of the month represented by this DateTime instance.

Returns:
The Epoch timestamp

getMonthDelta

public long getMonthDelta(java.util.TimeZone tz,
                          int deltaMo)
Returns the Epoch timestamp representing the current date, plus the number of months offset.

Parameters:
tz - The overriding TimeZone
deltaMo - The delta monnths (added to the month represented by this DateTime instance)
Returns:
The Epoch timestamp

getDayStartGMT

public long getDayStartGMT()
Returns the Epoch timestamp representing the start of the current day represented by this DateTime instance, based on the GMT TimeZone.

Returns:
The Epoch timestamp

getDayEndGMT

public long getDayEndGMT()
Returns the Epoch timestamp representing the end of the current day represented by this DateTime instance, based on the GMT TimeZone.

Returns:
The Epoch timestamp

isFuture

public boolean isFuture(long deltaSec)
Returns true if the this DateTime is more than the specified seconds into the future.

Parameters:
deltaSec - The number of seconds into the future.
Returns:
True if this DateTime is more than the specified seconds into the future.

isAfter

public boolean isAfter(DateTime dt)
Returns true if the this DateTime is after the specified DateTime instance

Parameters:
dt - the other DateTime instance
Returns:
True if this DateTime is after the specified DateTime instance.

isAfter

public boolean isAfter(DateTime dt,
                       boolean inclusive)
Returns true if the this DateTime is after the specified DateTime instance

Parameters:
dt - the other DateTime instance
inclusive - True to test for this "equal-to or after" the specified date, false to test only for "after".
Returns:
True if this DateTime is after the specified DateTime instance (or "equal-to" if 'inclusive' is true).

isBefore

public boolean isBefore(DateTime dt)
Returns true if this DateTime is before the specified DateTime instance

Parameters:
dt - the other DateTime instance
Returns:
True if this DateTime is before the specified DateTime instance

isBefore

public boolean isBefore(DateTime dt,
                        boolean inclusive)
Returns true if this DateTime is before the specified DateTime instance

Parameters:
dt - the other DateTime instance
inclusive - True to test for "equal-to or before", false to test only for "before".
Returns:
True if this DateTime is before the specified DateTime instance (or "equal-to" if 'inclusive' is true).

getYearsSince

public double getYearsSince(DateTime priorDate)
Return the number of years since specified date (year/month/day).

Parameters:
priorDate - Prior date
Returns:
Number of years (and fractional years)

getYearsSince

public double getYearsSince(DateTime priorDate,
                            java.util.TimeZone tz)
Return the number of years since specified date (year/month/day).

Parameters:
priorDate - Prior date
Returns:
Number of years (and fractional years)

getYearsSince

public double getYearsSince(int year,
                            int month1,
                            int day)
Return the number of years since specified date (year/month/day).

Parameters:
year - Prior year
month1 - Month of prior year (1..12)
day - Day of month
Returns:
Number of years (and fractional years)

getYearsSince

public double getYearsSince(long priorDayNumber)
Return the number of years since specified date (year/month/day).

Parameters:
priorDayNumber - Prior day-number
Returns:
Number of years (and fractional years)

getYearsSince

public double getYearsSince(long priorDayNumber,
                            java.util.TimeZone tz)
Return the number of years since specified date (year/month/day).

Parameters:
priorDayNumber - Prior day-number
tz - TimeZone
Returns:
Number of years (and fractional years)

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified DateTime is equal-to this DateTime instance

Overrides:
equals in class java.lang.Object
Parameters:
obj - the other DateTime instance
Returns:
True if the specified DateTime is equal-to this DateTime instance

compareTo

public int compareTo(java.lang.Object other)
Compares another DateTime instance to this instance.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
other - The other DateTime instance.
Returns:
<0 of the other DateTime instance is before this instance, 0 if the other DateTime instance is equal to this instance, and >0 if the other DateTime instance is after this instance.

_timeZone

protected java.util.TimeZone _timeZone(java.util.TimeZone tz)
Returns a non-null TimeZone

Parameters:
tz - The TimeZone returned (if non-null)
Returns:
The specified TimeZone, or the default TimeZone if the specified TimeZone is null

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the default (or current) TimeZone

Returns:
The default (or current) TimeZone

getTimeZoneID

public java.lang.String getTimeZoneID()
Returns the ID of the current TimeZone

Returns:
The ID of the current TimeZone

getTimeZoneShortName

public java.lang.String getTimeZoneShortName()
Returns the short-name of the current TimeZone

Returns:
The short-name of the current TimeZone

setTimeZone

public void setTimeZone(java.util.TimeZone tz)
Sets the current TimeZone

Parameters:
tz - The TimeZone to set

setTimeZone

public void setTimeZone(java.lang.String tz)
Sets the current TimeZone

Parameters:
tz - The TimeZone ID to set

readTimeZones

public static java.lang.String[] readTimeZones(java.io.File tmzFile)
Reads the available TimeZone IDs from the specified file.

Parameters:
tmzFile - The file from which TimeZone IDs are read.
Returns:
A String array of read TimeZone IDs.

isValidTimeZone

public static boolean isValidTimeZone(java.lang.String tzid)
Returns true if the specified TimeZone is valid

Parameters:
tzid - The String representation of a TimeZone
Returns:
True if the TimeZone is valid, false otherwise

getTimeZone

public static java.util.TimeZone getTimeZone(java.lang.String tzid,
                                             java.util.TimeZone dft)
Gets the TimeZone instance for the specified TimeZone id

Parameters:
tzid - The TimeZone id
dft - The default TimeZone to return if the specified TimeZone id does not exist.
Returns:
The TimZone

getTimeZone

public static java.util.TimeZone getTimeZone(java.lang.String tzid)
Gets the TimeZone instance for the specified TimeZone id

Parameters:
tzid - The TimeZone id
Returns:
The TimeZone

getDefaultTimeZone

public static java.util.TimeZone getDefaultTimeZone()
Returns the default TimeZone

Returns:
The default TimeZone

getGMTTimeZone

public static java.util.TimeZone getGMTTimeZone()
Returns the GMT TimeZone

Returns:
The GMT TimeZone

toString

public java.lang.String toString()
Returns a String representation of this DateTime instance

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.util.TimeZone tmz)
Returns a String representation of this DateTime instance


format

public static java.lang.String format(java.util.Date date,
                                      java.util.TimeZone tz,
                                      java.lang.String dtFmt)
Formats the specified Date instance.

Parameters:
date - The Date instance
tz - The TimeZone
dtFmt - The Date/Time format
Returns:
The String representation of the StringBuffer destination.

format

public java.lang.String format(java.lang.String dtFmt,
                               java.util.TimeZone tz,
                               java.lang.StringBuffer sb)
Formats the current DateTime instance.

Parameters:
dtFmt - The Date/Time format
tz - The overriding TimeZone
sb - The StringBuffer where the formatted Date/Time is placed (may be null)
Returns:
The String representation of the StringBuffer destination.

format

public java.lang.String format(java.lang.String fmt,
                               java.util.TimeZone tz)
Formats the current DateTime instance.

Parameters:
fmt - The Date/Time format
tz - The overriding TimeZone
Returns:
The formatted Date/Time String

shortFormat

public java.lang.String shortFormat(java.util.TimeZone tz)
Formats the current DateTime instance (using format "MMM dd, yyyy HH:mm:ss z")

Parameters:
tz - The overriding TimeZone
Returns:
The formatted Date/Time String

format

public java.lang.String format(java.util.TimeZone tz)
Formats the current DateTime instance (using format "MMM dd, yyyy HH:mm:ss z")

Parameters:
tz - The overriding TimeZone
Returns:
The formatted Date/Time String

format

public java.lang.String format(java.lang.String fmt)
Formats the current DateTime instance.

Parameters:
fmt - The Date/Time format
Returns:
The formatted Date/Time String

gmtFormat

public java.lang.String gmtFormat(java.lang.String fmt)
Formats the current DateTime instance, based on the GMT TimeZone.

Parameters:
fmt - The Date/Time format
Returns:
The formatted Date/Time String

gmtFormat

public java.lang.String gmtFormat()
Formats the current DateTime instance (using format "yyyy/MM/dd HH:mm:ss 'GMT'"), based on the GMT TimeZone.

Returns:
The formatted Date/Time String

gmtFormat

public java.lang.String gmtFormat(java.lang.String fmt,
                                  java.lang.StringBuffer sb)
Formats the current DateTime instance, based on the GMT TimeZone.

Parameters:
fmt - The Date/Time format
sb - The StringBuffer where the formatted Date/Time is placed (may be null)
Returns:
The String representation of the StringBuffer destination.

clone

public java.lang.Object clone()
Returns a clone of this DateTime instance

Overrides:
clone in class java.lang.Object
Returns:
A clone of this DateTime instance

encodeHourMinuteSecond

public static java.lang.String encodeHourMinuteSecond(long tod,
                                                      java.lang.String fmt)
Formats the time-of-day, based on the specified format.

Parameters:
tod - The time-of-day
fmt - The format
Returns:
The formatted time-of-day

parseHourMinuteSecond

public static int parseHourMinuteSecond(java.lang.String hms)
Parses the specified "hhhh:mm:ss" String into the number of represented seconds

Parameters:
hms - The String containing the "hhhh:mm:ss" to parse
Returns:
The number of seconds represented by the specified String format

parseHourMinuteSecond

public static int parseHourMinuteSecond(java.lang.String hms,
                                        int dft)
Parses the specified "hhhh:mm:ss" String into the number of represented seconds

Parameters:
hms - The String containing the "hhhh:mm:ss" to parse
dft - The default seconds returned if unable to parse the specified String.
Returns:
The number of seconds represented by the specified String format

main

public static void main(java.lang.String[] argv)
Main entry point for testing/debugging

Parameters:
argv - Comand-line arguments