public class DynamicDate extends Date
getInstance(java.lang.String).
Sadly, the Date object of Sun is implemented using private static methods which use private
fields of the Date object, so not everything could be overridden perfectly. So, if e.g. a dynamic
date could be an argument of an 'after' or 'before' method, it is better to wrap it with eval(java.lang.String) first.
Basicly the following dynamic dates are possible:
getDemo() returns a list of several strings which can be parsed.| Modifier and Type | Field and Description |
|---|---|
protected String |
date
The original string by which this instance was gotten.
|
| Modifier | Constructor and Description |
|---|---|
protected |
DynamicDate(String d) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
after(Date when) |
boolean |
before(Date when) |
Object |
clone() |
int |
compareTo(Date anotherDate) |
boolean |
equals(Object obj) |
static Date |
eval(Date date)
Makes sure the argument 'date' is no DynamicDate any more.
|
static Date |
eval(String format)
This calls
getInstance(java.lang.String), then eval(java.lang.String) and catches the parse-exception (in which
case it will return -1). |
protected Date |
evalDate()
This produces a normal Date object, and is called everytime when that is needed.
|
int |
getDate()
Deprecated.
|
int |
getDay()
Deprecated.
|
static String[] |
getDemo()
Returns an arrays of example Strings that can be parsed by DynamicDate.
|
String |
getFormat() |
int |
getHours()
Deprecated.
|
static Date |
getInstance(String format)
Parses a format string and returns Date instance, possibly a 'dynamic one'.
|
int |
getMinutes()
Deprecated.
|
int |
getMonth()
Deprecated.
|
int |
getSeconds()
Deprecated.
|
long |
getTime() |
int |
getTimezoneOffset()
Deprecated.
|
int |
getYear()
Deprecated.
|
int |
hashCode() |
static void |
main(String[] argv) |
void |
setDate(int date)
Deprecated.
|
void |
setHours(int hours)
Deprecated.
|
void |
setMinutes(int minutes)
Deprecated.
|
void |
setMonth(int month)
Deprecated.
|
void |
setSeconds(int seconds)
Deprecated.
|
void |
setTime(long time)
Deprecated.
|
void |
setYear(int year)
Deprecated.
|
String |
toGMTString()
Deprecated.
|
String |
toLocaleString()
Deprecated.
|
String |
toString() |
protected final String date
protected DynamicDate(String d)
public static Date getInstance(String format) throws ParseException
ParseExceptionpublic static Date eval(String format)
getInstance(java.lang.String), then eval(java.lang.String) and catches the parse-exception (in which
case it will return -1).
This boils down to that this is a utility method to get a new Date object by String in just
one call.public static Date eval(Date date)
public String getFormat()
protected Date evalDate()
eval(Date), which
will work on a normal Date object too.public int compareTo(Date anotherDate)
compareTo in interface Comparable<Date>compareTo in class Date@Deprecated public int getDate()
@Deprecated public int getDay()
@Deprecated public int getHours()
@Deprecated public int getMinutes()
getMinutes in class Date@Deprecated public int getMonth()
@Deprecated public int getSeconds()
getSeconds in class Date@Deprecated public int getTimezoneOffset()
getTimezoneOffset in class Date@Deprecated public int getYear()
@Deprecated public void setDate(int date)
@Deprecated public void setHours(int hours)
@Deprecated public void setMinutes(int minutes)
setMinutes in class Date@Deprecated public void setMonth(int month)
@Deprecated public void setSeconds(int seconds)
setSeconds in class Date@Deprecated public void setTime(long time)
@Deprecated public void setYear(int year)
@Deprecated public String toGMTString()
toGMTString in class Date@Deprecated public String toLocaleString()
toLocaleString in class Datepublic static String[] getDemo()
public static void main(String[] argv) throws ParseException, ParseException
ParseExceptionMMBase 1.9-SNAPSHOT - ${javadoctimestamp}