QJCC homepage

biz.chitec.quarterback.util
Class EDate

java.lang.Object
  extended bybiz.chitec.quarterback.util.EDate
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class EDate
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

Date and time range class with arithmetic capabilities.

General capabilities

EDate can store dates and time ranges. It should be seen in conjunction with the date representing classes of the Java standard classes. Compared to them, EDate focuses on arithmetic functions. It does not have the generalization in date representations Calendar and friends offer. EDate does always work with the Gregorian calendar in mind and days which have 24 flat-numbered hours. EDate's capability of representing time ranges has no equivalent within the java.util classes.

Internal structure

Internally, EDate uses a representation based on storing seconds, minutes, hours, days, months and years separately (with time ranges not having month and year values). Arithmetic works always partwise with immideate normalisation. EDate uses a local, flat time model, it does not care about time zones, daylight saving times or leap seconds. It does only know about the time model of the Gregorian Calendar. It does however, take care about time zones when it comes to transferring from and to the epoch. Normally, it behaves to be in the local and current timezone and cares about daylight saving times.

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.

Midnight representation

While from the mathematical point of view times are always in the (including) range from 00:00:00 to 23:59:59, EDate allows the time specification 24:00:00, which is midnight and equvalent to 00:00:00 of the next day. You can force EDate to turn a midnight date into this special representation by calling force24(). This does NOT have any effect on the special access methods for database access. Generally, the representation is abandonned as soon as any arithmetic takes place on the date. Time ranges do never have an hour number of "24".

Internationalization and time zones

EDate has internationalized capabilites of presenting its settings. It can be transformed from and into a standard Java Date instance to be processed by DateFormat or similar classes.

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.

Version:
$Id: 7518c15fdbad07a2ef8f03443911a1e429ea09d3 $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000-2003, cantamen/Dirk Hillbrecht 2003-2005 Distributed under the terms of the GNU LGPL .
See Also:
Serialized Form

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

immideately

public static final EDate immideately

immediately

public static final EDate immediately

oneminute

public static final EDate oneminute

twominutes

public static final EDate twominutes

fiveminutes

public static final EDate fiveminutes

fiveteenminutes

public static final EDate fiveteenminutes

thirtyminutes

public static final EDate thirtyminutes

halfhour

public static final EDate halfhour

fourtyfiveminutes

public static final EDate fourtyfiveminutes

onehour

public static final EDate onehour

twohours

public static final EDate twohours

threehours

public static final EDate threehours

fivehours

public static final EDate fivehours

sixhours

public static final EDate sixhours

oneday

public static final EDate oneday

twodays

public static final EDate twodays

threedays

public static final EDate threedays

oneweek

public static final EDate oneweek

twoweeks

public static final EDate twoweeks

sixweeks

public static final EDate sixweeks

UTC_ZONE

public static final java.util.TimeZone UTC_ZONE

LOCAL_ZONE

public static final java.util.TimeZone LOCAL_ZONE

epochstart

private static final EDate epochstart

FIRSTOFJANUARYIN1600

private static final EDate FIRSTOFJANUARYIN1600

year

protected int year

month

protected int month

day

protected int day

hour

protected int hour

minute

protected int minute

second

protected int second

calcyear

protected int calcyear

calcmonth

protected int calcmonth

calcday

protected int calcday

calchour

protected int calchour

maxday

protected int[] maxday

oy

private int oy

om

private int om

od

private int od

oh

private int oh

omi

private int omi

os

private int os

ocy

private int ocy

ocm

private int ocm

ocd

private int ocd

omx

private int[] omx

srbs

private static transient java.util.Map srbs
Constructor Detail

EDate

public EDate(int ye,
             int mo,
             int da,
             int ho,
             int mi,
             int se)
date constructor. All parameters must be legal.


EDate

public EDate(int da,
             int ho,
             int mi,
             int se)
time range constructor. Parameters are normalized automatically (e.g. (0,0,0,120) is transformed to (0,0,2,0).


EDate

public EDate(int thesecs)
time range constructor. Parameter is interpreted as a time range in seconds.


EDate

public EDate(long themillisecs,
             boolean local)
Create EDate in local time from some epoch-wise milliseconds. With local set to true, the epoch is assumed not to be based on UTC timezone, but on local timezone (and therefore no real epoch...)


EDate

public 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. If given timezone is different from UTC or GMT, time is evaluated in the given time zone. DST is evaluated accordingly to time zone information.

Parameters:
themillisecs - Epoch value to use
tz - timezone to evaluate epoch value in

EDate

public EDate(java.util.TimeZone tz)
Create EDate with the current time in the given timezone.

Parameters:
tz - timezone to evaluate the current time in

EDate

public EDate(long themillisecs)
Create EDate in local time from epoch-wise milliseconds in UTC.


EDate

public EDate()
initialize with local system time


EDate

public 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. Otherwise, local time is used.


EDate

public EDate(java.util.Date d)
initialize from a java.util.Date object. The Date must return the correct local time.


EDate

public EDate(java.lang.String ds)
String constructor. Handles both dates and time ranges. Time ranges are any string with at least 8 characters that only contain 0-9 and ":" at last but 7th position, e.g. 0:003000 (half an hour). Dates are any String with 14 numerical chars which must be yyyymmddhhmmss. E.g. legal are "19970918130000" or "1997-09-18 13:00:00". If the date contains a subsecond part at the end (e.g. ".9" in "2005-06-07 13:04:53.9"), it is removed automatically.


EDate

public EDate(EDate o)
Copy constructor. Copy this EDate verbatim from another.

Method Detail

getRB

private static java.util.ResourceBundle getRB(java.util.Locale lo)

getRB

private static java.util.ResourceBundle getRB()

initFromSeconds

public void initFromSeconds(int thesecs)
Time range re-initializer. Parameter is interpreted as a time range in seconds.


initFromDate

public void initFromDate(java.util.Date d)

afterInit

private void afterInit()
checks after initialization


debugOut

public java.lang.String debugOut()

setCalcDate

private void setCalcDate()

copyFrom

public void copyFrom(EDate o)
copy data from other EDate


isLeapYear

public static boolean isLeapYear(int year)
static method: returns if the given year is a leap year. Conforms to all rules.


isLeapYear

public boolean isLeapYear()
returns if the current year of this EDate is a leap year.


calcmonthlengths

protected final void calcmonthlengths()
calculate month lengths, esp. the length of February with respect to leap years.


isrange

public boolean isrange()
true iff EDate object represents a time range


isdate

public boolean isdate()
true iff EDate object represents a date


backupState

private void backupState()

restoreState

private void restoreState()

setYear

public void setYear(int ny)

setMonth

public void setMonth(int n)

setDay

public void setDay(int n)

setYMD

public void setYMD(int ny,
                   int nm,
                   int nd)

setHour

public void setHour(int n)

setMinute

public void setMinute(int n)

setSecond

public void setSecond(int n)

setHMS

public void setHMS(int h,
                   int m,
                   int s)

getYear

public int getYear()

getMonth

public int getMonth()

getMaxDayOfCurrentMonth

public int getMaxDayOfCurrentMonth()

getDay

public int getDay()

getHour

public int getHour()

getHour

public int getHour(boolean ampmmode)

isAM

public boolean isAM()

getMinute

public int getMinute()

getSecond

public int getSecond()

checkDayForMaxMonthLength

private void checkDayForMaxMonthLength()

incYear

public void incYear()

decYear

public void decYear()

incMonth

public void incMonth()

incMonth

public void incMonth(boolean allowoverflow)

incMonth

public void incMonth(boolean allowoverflow,
                     int incstep)

decMonth

public void decMonth()

decMonth

public void decMonth(boolean allowoverflow)

decMonth

public void decMonth(boolean allowoverflow,
                     int decstep)

incDay

public void incDay()
Increment day, but do not allow overflow into the next month.


incDay

public void incDay(boolean allowoverflow)

incDay

public void incDay(boolean allowoverflow,
                   int incstep)

decDay

public void decDay()
Decrement day, but do not allow overflow into the previous month.


decDay

public void decDay(boolean allowoverflow)

decDay

public void decDay(boolean allowoverflow,
                   int decstep)

incHour

public void incHour()

decHour

public void decHour()

incMinute

public void incMinute()

decMinute

public void decMinute()

incSecond

public void incSecond()

decSecond

public void decSecond()

add

public void add(EDate other)
adds a time range to a date or another time range


addSeconds

public void addSeconds(int secs)
add a small amount of seconds to the date


sub

public void sub(EDate other)
subtracts a time range from a date or a time range


mul

public void mul(int factor)
multiplies a time range with a literal


daysFrom1600

public 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...). For time ranges, the "day"-value is returned unchanged.


distance

public EDate distance(EDate other)
returns the difference between two dates or two time ranges as a new time range object. It is always positive.


normalize

private final void normalize()
normalizes the date or time range (second and minute between 0 and 59, hour between 0 and 23, etc.)


compareTo

public int compareTo(java.lang.Object o)
Compares this EDate to the other. Returns 1 if this is greater (=later), -1 if this is earlier, 0 on equality.

Specified by:
compareTo in interface java.lang.Comparable

timeOnlyCompareTo

public int timeOnlyCompareTo(EDate other)
Compares the time part of this EDate to the other EDate. Returns 1 if this is greater (=later), -1 if this is earlier, 0 on equality.


basicEqualsLater

private boolean basicEqualsLater(EDate other,
                                 boolean defval)
Common helper method for laterThan and equalsOrLaterThan.


timeOnlyBasicEqualsLater

private boolean timeOnlyBasicEqualsLater(EDate other,
                                         boolean defval)
Common helper method for timeOnlyLaterThan and timeOnlyEqualsOrLaterThan.


laterThan

public boolean laterThan(EDate other)
returns if this EDate object is later (or for time ranges: larger) than the other EDate object.


equalsOrLaterThan

public boolean equalsOrLaterThan(EDate other)
true iff this EDate object is later (or for time ranges: larger) than or equal to the other EDate object.


equals

public boolean equals(java.lang.Object other)
true iff other is an EDate and equals this one


timeOnlyLaterThan

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


timeOnlyEqualsOrLaterThan

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


timeOnlyEquals

public boolean timeOnlyEquals(EDate o)
true iff time of other equals to time of this one


equalsYMD

public boolean equalsYMD(EDate o)
checks equality in date (year, month, date)


equalsHMS

public boolean equalsHMS(EDate o)
checks equality in time (hour, minte, and second)


asSeconds

public long asSeconds()
returns this EDate as seconds (either the time range or the difference between this EDate and Dec., 31st, 1599, 00:00:00).


fromEpoch

public void fromEpoch(long themillisecs,
                      java.util.TimeZone tz)
Initializes the EDate from an epoch value into the given timezone. The EDate is changed into representing the given epoch value in the given timezone. The epoch is always assumed to be UTC-based.

Parameters:
themillisecs -
tz -

toEpoch

public long toEpoch(java.util.TimeZone tz)
Convert EDate into milliseconds in the Unix epoch. EDate is interpreted being in the given time zone. DST is handled correctly.

Parameters:
tz - TimeZone to interpret EDate being in
Returns:
time in milliseconds relative to the unix epoch.

toEpoch

public long toEpoch(java.util.Calendar cal)
Convert EDate into milliseconds using the given Calendar object. The calendar will handle the actual conversion. This method is only needed for cases where a huge number of EDates has to be converted and the calendar should not be loaded each time again.

Parameters:
cal - Calendar to do the conversion job
Returns:
time in milliseconds relative to the unix epoch.

toEpoch

public long toEpoch(boolean local)
Returns current local date in milliseconds in the Unix epoch. The date is either interpreted as being in the local time zone (local=true) or in UTC timezone (local=false). The epoch is always UTC-based. Local time conversion obeys DST.

Parameters:
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).

toEpoch

public long toEpoch()
Returns the represented local date in UTC-epoch-wise milliseconds.


getDayOfWeek

public int getDayOfWeek()
returns day of the week 0 means Monday, 1 Tuesday etc., Sunday is 6.


dayOfWeek

public java.lang.String dayOfWeek(boolean shortver)
returns day of the week (long or short version) for now, German week day names are returned. This will change to a locale dependent system


allDaysOfWeek

public static java.lang.String[] allDaysOfWeek(boolean shortver,
                                               java.util.Locale lo)
Return all names of the days of the week. This is done internationalized by the means of i18n'd ResourceBundles.


allDaysOfWeek

public static java.lang.String[] allDaysOfWeek(boolean shortver)
Return all names of the days of the week. This is done internationalized by the means of i18n'd ResourceBundles.


getDayPart

public EDate getDayPart()
Return this very EDate with hour, minute and second set to zero.


normTo

public void normTo(EDate other)
Normalize EDate to another. From second to hour: If other.[field] is zero, set same field zero here. If field is not zero, make same field here multiple of value the other's field. Always make equal or smaller! Leave all higher fields untouched.


isNormedTo

public boolean isNormedTo(EDate norm)
Return whether this EDate is normed to the EDate "norm". Only second, minute, and hour are checked. My time must be multiple of norm's time.


normalizeCanonical

public EDate normalizeCanonical(int rangesymbol)
Normlizes the EDate to a canonical time range matching the range symbol. Canonical time ranges are defined by the constants of the EDateRangeSymbols class and define time ranges as daily, weekly, monthly or quarterly. The ranges are called "canonical" as they are always counted as typical, e.g. "monthly" always begins on the 1st day of a month, "quarterly" on the first of January, April, July, or October. The date is normalized to the next smaller range begin. If it matches a range begin, it is not changed. The time is always set to midnight, 0:00, 12:00am. Weeks begin on Monday. Biweekly ranges are continuous through the years, i.e. they do not follow the weeks numbers within the year, but a global counting taking an ad-hoc definition of week 1.

Parameters:
rangesymbol - time range description as of EDateRangeSymbols

normalizeTo

public 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. The result is always less than or equal to the current setting.

Parameters:
start - A date from which we start counting
rangesymbol - A time range

incCanonical

public EDate incCanonical(int rangesymbol)
Increments the date according to a canonical time range. For the sake of efficiency, the date is assumed to be already normalized according the to same or a compatible canonical time range. The assumption is not checked. If it is false, the results will be mathematically correct but somehow bogus (as the spawned interval is not canonical any more).

Parameters:
rangesymbol - time range description as of EDateRangeSymbols

decCanonical

public EDate decCanonical(int rangesymbol)
Decrements the date according to a canonical time range. For the sake of efficiency, the date is assumed to be already normalized according the to same or a compatible canonical time range. The assumption is not checked. If it is false, the results will be mathematically correct but somehow bogus (as the spawned interval is not canonical any more).

Parameters:
rangesymbol - time range description as of EDateRangeSymbols

zFill

private java.lang.String zFill(java.lang.String s,
                               int len)
Fill a string up to length "len" with leading zero's "0"


getDMY

public java.lang.String getDMY()
Return day, month, and year in a printable version.


getDM

public java.lang.String getDM()
Return day, and month in a printable version.


getHM

public java.lang.String getHM()
Return hour and minute in a printable version.


getI18NDate

public java.lang.String getI18NDate(boolean withweekday,
                                    java.util.Locale lo)
Get i18n representation of this EDate as date in the given locale

Parameters:
withweekday - If true, puts day of the week into output
lo - The locale to return this date in
Returns:
String containing i18n representation.

getI18NDMY

public 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

Parameters:
withweekday - If true, puts day of the week into output
lo - The locale to return this date in
Returns:
String containing i18n representation.

getI18NDM

public 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

Parameters:
withweekday - If true, puts day of the week into output
lo - The locale to return this date in
Returns:
String containing i18n representation.

getI18NDuration

public java.lang.String getI18NDuration(boolean convertdaystohours,
                                        java.util.Locale lo)
Get i18n representation of this EDate as duration in the standard locale

Parameters:
convertdaystohours - Convert days to hours, i.e. only print hours and below
lo - The locale to return this date in
Returns:
String containing i18n representation.

getI18NDuration

public 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,

Parameters:
lo - The locale to return this date in
Returns:
String containing i18n representation.

getI18NDate

public java.lang.String getI18NDate(boolean withweekday)
Get i18n representation of this EDate as date in the standard locale

Parameters:
withweekday - If true, puts day of the week into output
Returns:
String containing i18n representation.

getI18NDMY

public java.lang.String getI18NDMY(boolean withweekday)
Get i18n representation of this EDate's date (not time) as date in the standard locale

Parameters:
withweekday - If true, puts day of the week into output
Returns:
String containing i18n representation.

getI18NDM

public java.lang.String getI18NDM(boolean withweekday)
Get i18n representation of this EDate's date (not time) without year as date in the standard locale

Parameters:
withweekday - If true, puts day of the week into output
Returns:
String containing i18n representation.

getI18NDuration

public java.lang.String getI18NDuration()
Get i18n representation of this EDate as duration in the standard locale

Returns:
String containing i18n representation.

getI18NDuration

public java.lang.String getI18NDuration(boolean convertdaystohours)
Get i18n representation of this EDate as duration in the standard locale

Parameters:
convertdaystohours - If true, convert days to hours and print sum of this instead of explicit days.
Returns:
String containing i18n representation.

getAccessDate

public java.lang.String getAccessDate()
Return date in a format understandable by MS Access


getEscapedAccessDate

public java.lang.String getEscapedAccessDate()
Return date in another format understandable by MS Access


getCSVDate

public java.lang.String getCSVDate(boolean leadingdatezero,
                                   boolean dinformat)
Return date in a format understandable by CSV interpreters. This method always returns the date with time in range "00:00:00" and "23:59:59".


getCSVDate

public java.lang.String getCSVDate(boolean leadingdatezero)

getCSVDate

public java.lang.String getCSVDate()

doReturnCSVDate

private final java.lang.String doReturnCSVDate(boolean leadingdatezero,
                                               boolean dinformat)

getLogFormatDate

public java.lang.String getLogFormatDate()
return date in a format nice for log files


toString

public java.lang.String toString()
convert EDate to string. Format is either YYYYMMDDhhmmss format or D:hhmmss for time ranges with "D" having as many digits as needed.

This method never returns a date with hour=24.


doReturnToStringDate

private final java.lang.String doReturnToStringDate()

abandon24

public EDate abandon24()

force24

public EDate force24()
returns new EDate representing this EDate, but with 24:00 instead of 00:00


toDate

public java.util.Date toDate()
transform to java.util.Date


convertFromTimeZonetoUTC

public 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. It converts the representation into UTC while taking care for time shifts, daylight saving times etc. The conversion is done in-situ, i.e. after calling this method the EDate might contain new day, hour, and minute values.

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.

Parameters:
tz - Source time zone to convert date from into UTC.

convertFromUTCtoTimeZone

public 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. It converts the representation into a local timezone taking care for time shifts, daylight saving time etc. The conversion is done in-situ, i.e. after calling this method the EDate might contain new day, hour, and minute values.

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.

Parameters:
tz - Target time zone to convert UTC date into.

QJCC homepage