org.mmbase.util
Class DynamicDate
java.lang.Object
java.util.Date
org.mmbase.util.DynamicDate
- All Implemented Interfaces:
- Cloneable, Comparable, Serializable
- public class DynamicDate
- extends Date
A DynamicDate is a Date object that has no fixed value, like 'now'. It is unmodifiable, so all
set-methods throw exceptions. There is no public constructor, but a public static 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 a 'after' or 'before' method, it is better to wrap it with eval(java.util.Date) first.
- Since:
- MMBase-1.8
- Author:
- Michiel Meeuwissen
- See Also:
- Serialized Form
|
Field Summary |
protected String |
date
The original string by which this instance was gotten. |
date
protected final String date
- The original string by which this instance was gotten.
DynamicDate
protected DynamicDate(String d)
getInstance
public static Date getInstance(String format)
throws ParseException
- Parses a format string and returns Date instance, possibly a 'dynamic one'. Not necessary a new one, which
does not matter, because these objects are unmodifiable anyway.
If the request date is not dynamic, but absolutely defined, a normal Date object is returned.
- Throws:
ParseException
eval
public static Date eval(Date date)
- Makes sure the argument 'date' is no DynamicDate any more. So this returns a fixed date
object when the argument is a DynamicDate and simply the argument if it is not.
getFormat
public String getFormat()
evalDate
protected Date evalDate()
- This produces a normal Date object, and is called everytime when that is needed. Users can call it too, if they want to fixated
after
public boolean after(Date when)
before
public boolean before(Date when)
clone
public Object clone()
compareTo
public int compareTo(Date anotherDate)
equals
public boolean equals(Object obj)
getDate
public int getDate()
getDay
public int getDay()
getHours
public int getHours()
getMinutes
public int getMinutes()
getMonth
public int getMonth()
getSeconds
public int getSeconds()
getTime
public long getTime()
getTimezoneOffset
public int getTimezoneOffset()
getYear
public int getYear()
hashCode
public int hashCode()
setDate
public void setDate(int date)
setHours
public void setHours(int hours)
setMinutes
public void setMinutes(int minutes)
setMonth
public void setMonth(int month)
setSeconds
public void setSeconds(int seconds)
setTime
public void setTime(long time)
setYear
public void setYear(int year)
toGMTString
public String toGMTString()
toLocaleString
public String toLocaleString()
toString
public String toString()
getDemo
public static String[] getDemo()
main
public static void main(String[] argv)
throws ParseException,
ParseException
- Throws:
ParseException
MMBase build 1.8.1.20060716