tribble.util
Class Date

java.lang.Object
  extended by java.util.Date
      extended by tribble.util.Date
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>

public class Date
extends java.util.Date

Immutable date/time value.

This class is identical to the standard java.util.Date class, except that its contents cannot be changed. Specifically, the setTime() method does not modify the object's value, but instead throws an exception. For all other purposes, objects of this type can be used anywhere java.util.Date objects are used.

Methods can return objects of this type as immutable values, i.e., the date objects cannot be modified after they are returned.

In addition, the special constants UNKNOWN and NEVER are provided which represent, respectively, an unknown date and a date that will never occur.

Since:
2003-02-10
Version:
$Revision: 1.1 $ $Date: 2003/02/26 01:22:01 $
Author:
David R. Tribble (david@tribble.com).
Copyright ©2003 by David R. Tribble, all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.
See Also:
Serialized Form

Field Summary
static Date NEVER
          Special date value: Never.
static long TIME_NEVER
          Special time value: Never.
static long TIME_UNKNOWN
          Special time value: Unknown.
static Date UNKNOWN
          Special date value: Unknown.
 
Constructor Summary
Date()
          Default constructor.
Date(java.util.Date date)
          Constructor.
Date(long time)
          Constructor.
 
Method Summary
 boolean after(java.util.Date when)
          Determine if this date occurs after a specified date.
 boolean before(java.util.Date when)
          Determine if this date occurs before a specified date.
 void setTime(long time)
          This method is not implemented.
 java.lang.String toString()
          Convert this date into its equivalent string representation.
 
Methods inherited from class java.util.Date
clone, compareTo, equals, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setYear, toGMTString, toLocaleString, UTC
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TIME_UNKNOWN

public static final long TIME_UNKNOWN
Special time value: Unknown.

See Also:
Constant Field Values

TIME_NEVER

public static final long TIME_NEVER
Special time value: Never.

See Also:
Constant Field Values

UNKNOWN

public static final Date UNKNOWN
Special date value: Unknown.


NEVER

public static final Date NEVER
Special date value: Never.

Constructor Detail

Date

public Date()
Default constructor. Sets this date to the current system time.

Since:
1.1, 2003-02-10

Date

public Date(long time)
Constructor.

Parameters:
time - A time value, measured in milliseconds since 1970-01-01 00:00:00.000 UTC.
Since:
1.1, 2003-02-10

Date

public Date(java.util.Date date)
Constructor.

Parameters:
date - A date value.
Since:
1.1, 2003-02-26
Method Detail

toString

public java.lang.String toString()
Convert this date into its equivalent string representation.

If this date is equal to UNKNOWN, the string returned is "unknown".

If this date is equal to NEVER, the string returned is "never".

Otherwise the string returned is of the form:

    "dow mon dd hh:mm:ss zzz yyyy" 
where:

Overrides:
toString in class java.util.Date
Returns:
A string representation of this date.
Since:
1.1, 2003-02-26

after

public boolean after(java.util.Date when)
Determine if this date occurs after a specified date.

Dates equal to UNKNOWN occur before any other valid date, and dates equal to NEVER occur after any other valid date.

Overrides:
after in class java.util.Date
Parameters:
when - Another date to compare to this one.
Returns:
True if this date is strictly later in time than when, otherwise false.
Since:
1.1, 2003-02-26

before

public boolean before(java.util.Date when)
Determine if this date occurs before a specified date.

Dates equal to UNKNOWN occur before any other valid date, and dates equal to NEVER occur after any other valid date.

Overrides:
before in class java.util.Date
Parameters:
when - Another date to compare to this one.
Returns:
True if this date is strictly earlier in time than when, otherwise false.
Since:
1.1, 2003-02-26

setTime

public void setTime(long time)
This method is not implemented.

Overrides:
setTime in class java.util.Date
Throws:
java.lang.UnsupportedOperationException - (unchecked) Thrown always, indicating that this method is not implemented.
Since:
1.1, 2003-02-10