|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object biz.chitec.quarterback.util.EDate
Date and time range class with arithmetic capabilities.
EDate does only work with positive dates and ranges. Date operation that work with week days or leap years work only with dates later than Jan, 1st, 1600.
The arithmetic model of EDate has no idea of time zones. The only problem that could arise if one works (implicitly) with a local time zone is that at switch times to and from daylight saving time, time range lengths are computed wrongly. If this is a problem, all time computations should be done using UTC or another flat time model - and conversion into any derived time zone should be done later.
EDate offers time zone conversion methods which transform the represented time in-situ. It should be clear that time range computations etc. do only make sense if all involved EDates represent the time in the same time zone.
This is an important and powerful class.
Field Summary | |
protected int |
calcday
|
protected int |
calchour
|
protected int |
calcmonth
|
protected int |
calcyear
|
protected int |
day
|
private static EDate |
epochstart
|
private static EDate |
FIRSTOFJANUARYIN1600
|
static EDate |
fivehours
|
static EDate |
fiveminutes
|
static EDate |
fiveteenminutes
|
static EDate |
fourtyfiveminutes
|
static EDate |
halfhour
|
protected int |
hour
|
static EDate |
immediately
|
static EDate |
immideately
|
static java.util.TimeZone |
LOCAL_ZONE
|
protected int[] |
maxday
|
protected int |
minute
|
protected int |
month
|
private int |
ocd
|
private int |
ocm
|
private int |
ocy
|
private int |
od
|
private int |
oh
|
private int |
om
|
private int |
omi
|
private int[] |
omx
|
static EDate |
oneday
|
static EDate |
onehour
|
static EDate |
oneminute
|
static EDate |
oneweek
|
private int |
os
|
private int |
oy
|
protected int |
second
|
static EDate |
sixhours
|
static EDate |
sixweeks
|
private static java.util.Map |
srbs
|
static EDate |
thirtyminutes
|
static EDate |
threedays
|
static EDate |
threehours
|
static EDate |
twodays
|
static EDate |
twohours
|
static EDate |
twominutes
|
static EDate |
twoweeks
|
static java.util.TimeZone |
UTC_ZONE
|
protected int |
year
|
Constructor Summary | |
EDate()
initialize with local system time |
|
EDate(boolean utc)
initialize with system time either in local time or in UTC If utc is set to true, the EDate gets the current time in UTC. |
|
EDate(java.util.Date d)
initialize from a java.util.Date object. |
|
EDate(EDate o)
Copy constructor. |
|
EDate(int thesecs)
time range constructor. |
|
EDate(int da,
int ho,
int mi,
int se)
time range constructor. |
|
EDate(int ye,
int mo,
int da,
int ho,
int mi,
int se)
date constructor. |
|
EDate(long themillisecs)
Create EDate in local time from epoch-wise milliseconds in UTC. |
|
EDate(long themillisecs,
boolean local)
Create EDate in local time from some epoch-wise milliseconds. |
|
EDate(long themillisecs,
java.util.TimeZone tz)
Create EDate from epoch in specified timezone The given milliseconds value is taken relatively to 1970-01-01 00:00:00 UTC. |
|
EDate(java.lang.String ds)
String constructor. |
|
EDate(java.util.TimeZone tz)
Create EDate with the current time in the given timezone. |
Method Summary | |
EDate |
abandon24()
|
void |
add(EDate other)
adds a time range to a date or another time range |
void |
addSeconds(int secs)
add a small amount of seconds to the date |
private void |
afterInit()
checks after initialization |
static java.lang.String[] |
allDaysOfWeek(boolean shortver)
Return all names of the days of the week. |
static java.lang.String[] |
allDaysOfWeek(boolean shortver,
java.util.Locale lo)
Return all names of the days of the week. |
long |
asSeconds()
returns this EDate as seconds (either the time range or the difference between this EDate and Dec., 31st, 1599, 00:00:00). |
private void |
backupState()
|
private boolean |
basicEqualsLater(EDate other,
boolean defval)
Common helper method for laterThan and equalsOrLaterThan. |
protected void |
calcmonthlengths()
calculate month lengths, esp. the length of February with respect to leap years. |
private void |
checkDayForMaxMonthLength()
|
int |
compareTo(java.lang.Object o)
Compares this EDate to the other. |
void |
convertFromTimeZonetoUTC(java.util.TimeZone tz)
Converts the date represented by this EDate from the given time zone to UTC The method assumes that EDate's current date is represented in the given timezone. |
void |
convertFromUTCtoTimeZone(java.util.TimeZone tz)
Converts the date represented by this EDate from UTC to given time zone The method assumes that EDate's current date is represented in UTC. |
void |
copyFrom(EDate o)
copy data from other EDate |
java.lang.String |
dayOfWeek(boolean shortver)
returns day of the week (long or short version) for now, German week day names are returned. |
int |
daysFrom1600()
returns the number of days between the current date of this EDate object and Dec. 31st, 1599 (so Jan, 1st, 1600 would give "1" as result and so on...). |
java.lang.String |
debugOut()
|
EDate |
decCanonical(int rangesymbol)
Decrements the date according to a canonical time range. |
void |
decDay()
Decrement day, but do not allow overflow into the previous month. |
void |
decDay(boolean allowoverflow)
|
void |
decDay(boolean allowoverflow,
int decstep)
|
void |
decHour()
|
void |
decMinute()
|
void |
decMonth()
|
void |
decMonth(boolean allowoverflow)
|
void |
decMonth(boolean allowoverflow,
int decstep)
|
void |
decSecond()
|
void |
decYear()
|
EDate |
distance(EDate other)
returns the difference between two dates or two time ranges as a new time range object. |
private java.lang.String |
doReturnCSVDate(boolean leadingdatezero,
boolean dinformat)
|
private java.lang.String |
doReturnToStringDate()
|
boolean |
equals(java.lang.Object other)
true iff other is an EDate and equals this one |
boolean |
equalsHMS(EDate o)
checks equality in time (hour, minte, and second) |
boolean |
equalsOrLaterThan(EDate other)
true iff this EDate object is later (or for time ranges: larger) than or equal to the other EDate object. |
boolean |
equalsYMD(EDate o)
checks equality in date (year, month, date) |
EDate |
force24()
returns new EDate representing this EDate, but with 24:00 instead of 00:00 |
void |
fromEpoch(long themillisecs,
java.util.TimeZone tz)
Initializes the EDate from an epoch value into the given timezone. |
java.lang.String |
getAccessDate()
Return date in a format understandable by MS Access |
java.lang.String |
getCSVDate()
|
java.lang.String |
getCSVDate(boolean leadingdatezero)
|
java.lang.String |
getCSVDate(boolean leadingdatezero,
boolean dinformat)
Return date in a format understandable by CSV interpreters. |
int |
getDay()
|
int |
getDayOfWeek()
returns day of the week 0 means Monday, 1 Tuesday etc., Sunday is 6. |
EDate |
getDayPart()
Return this very EDate with hour, minute and second set to zero. |
java.lang.String |
getDM()
Return day, and month in a printable version. |
java.lang.String |
getDMY()
Return day, month, and year in a printable version. |
java.lang.String |
getEscapedAccessDate()
Return date in another format understandable by MS Access |
java.lang.String |
getHM()
Return hour and minute in a printable version. |
int |
getHour()
|
int |
getHour(boolean ampmmode)
|
java.lang.String |
getI18NDate(boolean withweekday)
Get i18n representation of this EDate as date in the standard locale |
java.lang.String |
getI18NDate(boolean withweekday,
java.util.Locale lo)
Get i18n representation of this EDate as date in the given locale |
java.lang.String |
getI18NDM(boolean withweekday)
Get i18n representation of this EDate's date (not time) without year as date in the standard locale |
java.lang.String |
getI18NDM(boolean withweekday,
java.util.Locale lo)
Get i18n representation of this EDate's date (not time) without year as date in the given locale |
java.lang.String |
getI18NDMY(boolean withweekday)
Get i18n representation of this EDate's date (not time) as date in the standard locale |
java.lang.String |
getI18NDMY(boolean withweekday,
java.util.Locale lo)
Get i18n representation of this EDate's date (not time) as date in the given locale |
java.lang.String |
getI18NDuration()
Get i18n representation of this EDate as duration in the standard locale |
java.lang.String |
getI18NDuration(boolean convertdaystohours)
Get i18n representation of this EDate as duration in the standard locale |
java.lang.String |
getI18NDuration(boolean convertdaystohours,
java.util.Locale lo)
Get i18n representation of this EDate as duration in the standard locale |
java.lang.String |
getI18NDuration(java.util.Locale lo)
Get i18n representation of this EDate as duration in the standard locale with days printed as days, |
java.lang.String |
getLogFormatDate()
return date in a format nice for log files |
int |
getMaxDayOfCurrentMonth()
|
int |
getMinute()
|
int |
getMonth()
|
private static java.util.ResourceBundle |
getRB()
|
private static java.util.ResourceBundle |
getRB(java.util.Locale lo)
|
int |
getSecond()
|
int |
getYear()
|
EDate |
incCanonical(int rangesymbol)
Increments the date according to a canonical time range. |
void |
incDay()
Increment day, but do not allow overflow into the next month. |
void |
incDay(boolean allowoverflow)
|
void |
incDay(boolean allowoverflow,
int incstep)
|
void |
incHour()
|
void |
incMinute()
|
void |
incMonth()
|
void |
incMonth(boolean allowoverflow)
|
void |
incMonth(boolean allowoverflow,
int incstep)
|
void |
incSecond()
|
void |
incYear()
|
void |
initFromDate(java.util.Date d)
|
void |
initFromSeconds(int thesecs)
Time range re-initializer. |
boolean |
isAM()
|
boolean |
isdate()
true iff EDate object represents a date |
boolean |
isLeapYear()
returns if the current year of this EDate is a leap year. |
static boolean |
isLeapYear(int year)
static method: returns if the given year is a leap year. |
boolean |
isNormedTo(EDate norm)
Return whether this EDate is normed to the EDate "norm". |
boolean |
isrange()
true iff EDate object represents a time range |
boolean |
laterThan(EDate other)
returns if this EDate object is later (or for time ranges: larger) than the other EDate object. |
void |
mul(int factor)
multiplies a time range with a literal |
private void |
normalize()
normalizes the date or time range (second and minute between 0 and 59, hour between 0 and 23, etc.) |
EDate |
normalizeCanonical(int rangesymbol)
Normlizes the EDate to a canonical time range matching the range symbol. |
EDate |
normalizeTo(EDate start,
int rangesymbol)
Normalizes the current date in a way that it is a full number of intervals of the given type away from the start date. |
void |
normTo(EDate other)
Normalize EDate to another. |
private void |
restoreState()
|
private void |
setCalcDate()
|
void |
setDay(int n)
|
void |
setHMS(int h,
int m,
int s)
|
void |
setHour(int n)
|
void |
setMinute(int n)
|
void |
setMonth(int n)
|
void |
setSecond(int n)
|
void |
setYear(int ny)
|
void |
setYMD(int ny,
int nm,
int nd)
|
void |
sub(EDate other)
subtracts a time range from a date or a time range |
private boolean |
timeOnlyBasicEqualsLater(EDate other,
boolean defval)
Common helper method for timeOnlyLaterThan and timeOnlyEqualsOrLaterThan. |
int |
timeOnlyCompareTo(EDate other)
Compares the time part of this EDate to the other EDate. |
boolean |
timeOnlyEquals(EDate o)
true iff time of other equals to time of this one |
boolean |
timeOnlyEqualsOrLaterThan(EDate other)
true iff time of this EDate object is later (or for time ranges: larger) than or equal to time of the other EDate object. |
boolean |
timeOnlyLaterThan(EDate other)
returns if time of this EDate object is later (or for time ranges: larger) than the time of other EDate object. |
java.util.Date |
toDate()
transform to java.util.Date |
long |
toEpoch()
Returns the represented local date in UTC-epoch-wise milliseconds. |
long |
toEpoch(boolean local)
Returns current local date in milliseconds in the Unix epoch. |
long |
toEpoch(java.util.Calendar cal)
Convert EDate into milliseconds using the given Calendar object. |
long |
toEpoch(java.util.TimeZone tz)
Convert EDate into milliseconds in the Unix epoch. |
java.lang.String |
toString()
convert EDate to string. |
private java.lang.String |
zFill(java.lang.String s,
int len)
Fill a string up to length "len" with leading zero's "0" |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final EDate immideately
public static final EDate immediately
public static final EDate oneminute
public static final EDate twominutes
public static final EDate fiveminutes
public static final EDate fiveteenminutes
public static final EDate thirtyminutes
public static final EDate halfhour
public static final EDate fourtyfiveminutes
public static final EDate onehour
public static final EDate twohours
public static final EDate threehours
public static final EDate fivehours
public static final EDate sixhours
public static final EDate oneday
public static final EDate twodays
public static final EDate threedays
public static final EDate oneweek
public static final EDate twoweeks
public static final EDate sixweeks
public static final java.util.TimeZone UTC_ZONE
public static final java.util.TimeZone LOCAL_ZONE
private static final EDate epochstart
private static final EDate FIRSTOFJANUARYIN1600
protected int year
protected int month
protected int day
protected int hour
protected int minute
protected int second
protected int calcyear
protected int calcmonth
protected int calcday
protected int calchour
protected int[] maxday
private int oy
private int om
private int od
private int oh
private int omi
private int os
private int ocy
private int ocm
private int ocd
private int[] omx
private static transient java.util.Map srbs
Constructor Detail |
public EDate(int ye, int mo, int da, int ho, int mi, int se)
public EDate(int da, int ho, int mi, int se)
public EDate(int thesecs)
public EDate(long themillisecs, boolean local)
public EDate(long themillisecs, java.util.TimeZone tz)
themillisecs
- Epoch value to usetz
- timezone to evaluate epoch value inpublic EDate(java.util.TimeZone tz)
tz
- timezone to evaluate the current time inpublic EDate(long themillisecs)
public EDate()
public EDate(boolean utc)
public EDate(java.util.Date d)
public EDate(java.lang.String ds)
public EDate(EDate o)
Method Detail |
private static java.util.ResourceBundle getRB(java.util.Locale lo)
private static java.util.ResourceBundle getRB()
public void initFromSeconds(int thesecs)
public void initFromDate(java.util.Date d)
private void afterInit()
public java.lang.String debugOut()
private void setCalcDate()
public void copyFrom(EDate o)
public static boolean isLeapYear(int year)
public boolean isLeapYear()
protected final void calcmonthlengths()
public boolean isrange()
public boolean isdate()
private void backupState()
private void restoreState()
public void setYear(int ny)
public void setMonth(int n)
public void setDay(int n)
public void setYMD(int ny, int nm, int nd)
public void setHour(int n)
public void setMinute(int n)
public void setSecond(int n)
public void setHMS(int h, int m, int s)
public int getYear()
public int getMonth()
public int getMaxDayOfCurrentMonth()
public int getDay()
public int getHour()
public int getHour(boolean ampmmode)
public boolean isAM()
public int getMinute()
public int getSecond()
private void checkDayForMaxMonthLength()
public void incYear()
public void decYear()
public void incMonth()
public void incMonth(boolean allowoverflow)
public void incMonth(boolean allowoverflow, int incstep)
public void decMonth()
public void decMonth(boolean allowoverflow)
public void decMonth(boolean allowoverflow, int decstep)
public void incDay()
public void incDay(boolean allowoverflow)
public void incDay(boolean allowoverflow, int incstep)
public void decDay()
public void decDay(boolean allowoverflow)
public void decDay(boolean allowoverflow, int decstep)
public void incHour()
public void decHour()
public void incMinute()
public void decMinute()
public void incSecond()
public void decSecond()
public void add(EDate other)
public void addSeconds(int secs)
public void sub(EDate other)
public void mul(int factor)
public int daysFrom1600()
public EDate distance(EDate other)
private final void normalize()
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public int timeOnlyCompareTo(EDate other)
private boolean basicEqualsLater(EDate other, boolean defval)
private boolean timeOnlyBasicEqualsLater(EDate other, boolean defval)
public boolean laterThan(EDate other)
public boolean equalsOrLaterThan(EDate other)
public boolean equals(java.lang.Object other)
public boolean timeOnlyLaterThan(EDate other)
public boolean timeOnlyEqualsOrLaterThan(EDate other)
public boolean timeOnlyEquals(EDate o)
public boolean equalsYMD(EDate o)
public boolean equalsHMS(EDate o)
public long asSeconds()
public void fromEpoch(long themillisecs, java.util.TimeZone tz)
themillisecs
- tz
- public long toEpoch(java.util.TimeZone tz)
tz
- TimeZone to interpret EDate being in
public long toEpoch(java.util.Calendar cal)
cal
- Calendar to do the conversion job
public long toEpoch(boolean local)
local
- If true, handle time as being in the local time zone. If false, date is assumed to be in UTC (i.e. no timezone conversion is performed).public long toEpoch()
public int getDayOfWeek()
public java.lang.String dayOfWeek(boolean shortver)
public static java.lang.String[] allDaysOfWeek(boolean shortver, java.util.Locale lo)
public static java.lang.String[] allDaysOfWeek(boolean shortver)
public EDate getDayPart()
public void normTo(EDate other)
public boolean isNormedTo(EDate norm)
public EDate normalizeCanonical(int rangesymbol)
rangesymbol
- time range description as of EDateRangeSymbolspublic EDate normalizeTo(EDate start, int rangesymbol)
start
- A date from which we start countingrangesymbol
- A time rangepublic EDate incCanonical(int rangesymbol)
rangesymbol
- time range description as of EDateRangeSymbolspublic EDate decCanonical(int rangesymbol)
rangesymbol
- time range description as of EDateRangeSymbolsprivate java.lang.String zFill(java.lang.String s, int len)
public java.lang.String getDMY()
public java.lang.String getDM()
public java.lang.String getHM()
public java.lang.String getI18NDate(boolean withweekday, java.util.Locale lo)
withweekday
- If true, puts day of the week into outputlo
- The locale to return this date in
public java.lang.String getI18NDMY(boolean withweekday, java.util.Locale lo)
withweekday
- If true, puts day of the week into outputlo
- The locale to return this date in
public java.lang.String getI18NDM(boolean withweekday, java.util.Locale lo)
withweekday
- If true, puts day of the week into outputlo
- The locale to return this date in
public java.lang.String getI18NDuration(boolean convertdaystohours, java.util.Locale lo)
convertdaystohours
- Convert days to hours, i.e. only print hours and belowlo
- The locale to return this date in
public java.lang.String getI18NDuration(java.util.Locale lo)
lo
- The locale to return this date in
public java.lang.String getI18NDate(boolean withweekday)
withweekday
- If true, puts day of the week into output
public java.lang.String getI18NDMY(boolean withweekday)
withweekday
- If true, puts day of the week into output
public java.lang.String getI18NDM(boolean withweekday)
withweekday
- If true, puts day of the week into output
public java.lang.String getI18NDuration()
public java.lang.String getI18NDuration(boolean convertdaystohours)
convertdaystohours
- If true, convert days to hours and print sum of this instead of explicit days.
public java.lang.String getAccessDate()
public java.lang.String getEscapedAccessDate()
public java.lang.String getCSVDate(boolean leadingdatezero, boolean dinformat)
public java.lang.String getCSVDate(boolean leadingdatezero)
public java.lang.String getCSVDate()
private final java.lang.String doReturnCSVDate(boolean leadingdatezero, boolean dinformat)
public java.lang.String getLogFormatDate()
public java.lang.String toString()
This method never returns a date with hour=24.
private final java.lang.String doReturnToStringDate()
public EDate abandon24()
public EDate force24()
public java.util.Date toDate()
public void convertFromTimeZonetoUTC(java.util.TimeZone tz)
This method handles DST according to the time zone information. Dates within the "missing hour" at the switch from normal to DST time are converted as if they were within DST. Dates within the "double hour" at the switch from DST to normal time are always handled to be in the "second" hour, i.e. they are always interpreted being in normal time (not DST) of the given timezone. Strictly spoken, the DST incarnation of the double hour in not convertible into UTC.
tz
- Source time zone to convert date from into UTC.public void convertFromUTCtoTimeZone(java.util.TimeZone tz)
This method handles DST according to the time zone information. The "missing hour" at the beginning of the target's DST is left out. If the UTC time maps to one of the "double hours" at the end of the target's DST, that time is returned without distinction. Strictly spoken, it is not possible to say which of the two hours is meant.
tz
- Target time zone to convert UTC date into.
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |