org.nakedobjects.object.value
Class Date

java.lang.Object
  extended byorg.nakedobjects.object.value.AbstractNakedValue
      extended byorg.nakedobjects.object.value.Magnitude
          extended byorg.nakedobjects.object.value.Date
All Implemented Interfaces:
java.io.Externalizable, Naked, NakedValue, java.io.Serializable

public class Date
extends Magnitude
implements java.io.Externalizable

Value object representing a date, time, or datestamp value.

This object does support value listeners.

See Also:
Serialized Form

Field Summary
static int DATE
           
static int DATE_TIME
           
static int TIME
           
 
Constructor Summary
Date()
           
Date(Date date)
           
Date(int type)
          Deprecated. Split across Date, Time and TimeStamp
Date(int hour, int minute)
          Deprecated.  
Date(int year, int month, int day)
           
Date(int day, int month, int year, int hour, int minute)
          Deprecated.  
Date(java.lang.String text, int type)
          Deprecated. - will not work across locales
 
Method Summary
 void add(int days, int months, int years)
          Add the specified days, years and months to this date value.
 boolean after(Date comparisonDate)
          Deprecated.  
 boolean before(Date comparisonDate)
          Deprecated.  
 java.util.Calendar calendarValue()
           
 void clear()
          Clears the value so that it is empty, i.e.
 void copyObject(Naked object)
          Copies the content of the specified object into this object.
 java.util.Date dateValue()
           
 java.util.Date getDate()
          Deprecated. replaced by dateValue
 org.apache.log4j.Logger getLogger()
          subclasses can override (didn't make abstract so that existing subclasses won't break)
 java.lang.String getObjectHelpText()
          Returns a textual desctiption of the object - its contents and possible uses.
 boolean isEmpty()
          Return true if the date is blank
 boolean isEqualTo(Magnitude date)
          returns true if the date of this object has the same value as the specified date
 boolean isLessThan(Magnitude date)
          returns true if the time of this object is earlier than the specified time
 long longValue()
          Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.
 void parse(java.lang.String dateString)
          Takes a user entry string which is parsed to set up the object.
 void readExternal(java.io.ObjectInput in)
           
 void reset()
          Reset this date so it contains the current date.
 void restoreString(java.lang.String data)
          Takes a storage string and uses it reinstate this value object to its previous state/
 boolean sameDayAs(Date as)
           
 boolean sameMonthAs(Date as)
           
 boolean sameWeekAs(Date as)
           
 boolean sameYearAs(Date as)
           
 java.lang.String saveString()
          Returns a basic string representation of this value for storage purposes.
 void setDate(java.util.Date date)
          Deprecated. replaced by setValue(Date)
 void setDate(int year, int month, int day)
          Deprecated. replaced by setValue
 void setDateTime(int day, int month, int year, int hour, int minute, int second)
          Deprecated.  
 void setTime(int hour, int minute, int second)
          Deprecated.  
 void setValue(java.util.Date date)
           
 void setValue(Date date)
           
 void setValue(int year, int month, int day)
          Sets this object's date to be the same as the specified day, month and year.
 Title title()
          Returns a Title object describing the object.
 void today()
          Sets this date value to todays date
 void toStartOfMonth()
           
 void toStartOfWeek()
           
 void toStartOfYear()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.nakedobjects.object.value.Magnitude
isBetween, isGreaterThan, isGreaterThanOrEqualTo, isLessThanOrEqualTo, isSameAs, max, min
 
Methods inherited from class org.nakedobjects.object.value.AbstractNakedValue
about, addNakedValueListener, checkCanOperate, contextualTitle, deepCopy, dumpObject, fireValueChanged, fireValueChanged, getClassName, getFullClassName, isNull, isValid, nakedValueListeners, removeNakedValueListener, setAbout, setNull, setValidity, summary, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATE

public static final int DATE
See Also:
Constant Field Values

TIME

public static final int TIME
See Also:
Constant Field Values

DATE_TIME

public static final int DATE_TIME
See Also:
Constant Field Values
Constructor Detail

Date

public Date()

Date

public Date(int type)
Deprecated. Split across Date, Time and TimeStamp

Create a Date object for storing a date of the specified type.

See Also:
Date, Time, TimeStamp

Date

public Date(int hour,
            int minute)
Deprecated.  

Create a Date object for storing a time with the time set to the specified hours and minutes.

See Also:
Time

Date

public Date(int year,
            int month,
            int day)

Date

public Date(int day,
            int month,
            int year,
            int hour,
            int minute)
Deprecated.  

Create a Date object for storing a timestamp with the time set to the specified day, month, year, hour and minute.

See Also:
TimeStamp

Date

public Date(java.lang.String text,
            int type)
Deprecated. - will not work across locales

Create a Date object by parsing the specified text and set the type to the specfied type.


Date

public Date(Date date)
Method Detail

add

public void add(int days,
                int months,
                int years)
Add the specified days, years and months to this date value.


after

public boolean after(Date comparisonDate)
Deprecated.  

returns true if the time of this object is later than the specified time

See Also:
Magnitude.isGreaterThan(org.nakedobjects.object.value.Magnitude)

before

public boolean before(Date comparisonDate)
Deprecated.  

returns true if the time of this object is earlier than the specified time

See Also:
isLessThan(org.nakedobjects.object.value.Magnitude)

clear

public void clear()
Description copied from interface: NakedValue
Clears the value so that it is empty, i.e. isEmpty returns true.

Specified by:
clear in interface NakedValue

copyObject

public void copyObject(Naked object)
Description copied from interface: Naked
Copies the content of the specified object into this object.

Specified by:
copyObject in interface Naked

dateValue

public java.util.Date dateValue()

calendarValue

public java.util.Calendar calendarValue()

getDate

public java.util.Date getDate()
Deprecated. replaced by dateValue

See Also:
dateValue()

getObjectHelpText

public java.lang.String getObjectHelpText()
Description copied from interface: Naked
Returns a textual desctiption of the object - its contents and possible uses.

Specified by:
getObjectHelpText in interface Naked
Overrides:
getObjectHelpText in class AbstractNakedValue

isEmpty

public boolean isEmpty()
Return true if the date is blank

Specified by:
isEmpty in interface Naked

isEqualTo

public boolean isEqualTo(Magnitude date)
returns true if the date of this object has the same value as the specified date

Specified by:
isEqualTo in class Magnitude

isLessThan

public boolean isLessThan(Magnitude date)
returns true if the time of this object is earlier than the specified time

Specified by:
isLessThan in class Magnitude

longValue

public long longValue()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.


parse

public void parse(java.lang.String dateString)
           throws ValueParseException
Description copied from interface: NakedValue
Takes a user entry string which is parsed to set up the object. This needs to accomodate punctuation and adornments such as currency signs.

Specified by:
parse in interface NakedValue
Throws:
ValueParseException
See Also:
NakedValue.restoreString(String)

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

reset

public void reset()
Reset this date so it contains the current date.

Specified by:
reset in interface NakedValue
See Also:
NakedValue.reset()

sameDayAs

public boolean sameDayAs(Date as)

sameWeekAs

public boolean sameWeekAs(Date as)

sameMonthAs

public boolean sameMonthAs(Date as)

sameYearAs

public boolean sameYearAs(Date as)

setDate

public void setDate(int year,
                    int month,
                    int day)
Deprecated. replaced by setValue

Sets this object's date to be the same as the specified day, month and year.


setValue

public void setValue(int year,
                     int month,
                     int day)
Sets this object's date to be the same as the specified day, month and year.


setDate

public void setDate(java.util.Date date)
Deprecated. replaced by setValue(Date)


setValue

public void setValue(java.util.Date date)

setValue

public void setValue(Date date)

setDateTime

public void setDateTime(int day,
                        int month,
                        int year,
                        int hour,
                        int minute,
                        int second)
Deprecated.  

Sets this object's date to be the same as the specified day, month, year, hour, minute and second.

See Also:
TimeStamp.setValue(int, int, int, int, int, int)

setTime

public void setTime(int hour,
                    int minute,
                    int second)
Deprecated.  

Sets this object's time to be the same as the specified hour, minute and second.

See Also:
Time.setValue(int, int)

toStartOfWeek

public void toStartOfWeek()

toStartOfMonth

public void toStartOfMonth()

toStartOfYear

public void toStartOfYear()

title

public Title title()
Description copied from interface: Naked
Returns a Title object describing the object.

Specified by:
title in interface Naked

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

restoreString

public void restoreString(java.lang.String data)
Description copied from interface: NakedValue
Takes a storage string and uses it reinstate this value object to its previous state/

Specified by:
restoreString in interface NakedValue
Parameters:
data -
See Also:
NakedValue.parse(String)

saveString

public java.lang.String saveString()
Description copied from interface: NakedValue
Returns a basic string representation of this value for storage purposes.

Specified by:
saveString in interface NakedValue

today

public void today()
Sets this date value to todays date


getLogger

public org.apache.log4j.Logger getLogger()
Description copied from class: AbstractNakedValue
subclasses can override (didn't make abstract so that existing subclasses won't break)

Overrides:
getLogger in class AbstractNakedValue