org.mmbase.util
Class DynamicDate

java.lang.Object
  extended byjava.util.Date
      extended byorg.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.
 
Constructor Summary
protected DynamicDate(String d)
           
 
Method Summary
 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.
protected  Date evalDate()
          This produces a normal Date object, and is called everytime when that is needed.
 int getDate()
           
 int getDay()
           
static String[] getDemo()
           
 String getFormat()
           
 int getHours()
           
static Date getInstance(String format)
          Parses a format string and returns Date instance, possibly a 'dynamic one'.
 int getMinutes()
           
 int getMonth()
           
 int getSeconds()
           
 long getTime()
           
 int getTimezoneOffset()
           
 int getYear()
           
 int hashCode()
           
static void main(String[] argv)
           
 void setDate(int date)
           
 void setHours(int hours)
           
 void setMinutes(int minutes)
           
 void setMonth(int month)
           
 void setSeconds(int seconds)
           
 void setTime(long time)
           
 void setYear(int year)
           
 String toGMTString()
           
 String toLocaleString()
           
 String toString()
           
 
Methods inherited from class java.util.Date
compareTo, parse, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

date

protected final String date
The original string by which this instance was gotten.

Constructor Detail

DynamicDate

protected DynamicDate(String d)
Method Detail

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