com.plumtree.openfoundation.util
Class XPDateTime

java.lang.Object
  extended by com.plumtree.openfoundation.util.XPDateTime
All Implemented Interfaces:
IXPComparable, java.lang.Comparable

public class XPDateTime
extends java.lang.Object
implements IXPComparable

Represents an instant in time, typically expressed as a date and time of day.


Field Summary
protected  java.util.Date dt
          Internal Date.
 
Constructor Summary
XPDateTime()
          Allocates a XPDateTime object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
XPDateTime(java.util.Date date)
          Allocates a XPDateTime object using the given date value.
XPDateTime(long millisecondsSinceEpoch)
          Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
 
Method Summary
 boolean After(XPDateTime when)
          Tests if this date is after the given date.
 boolean Before(XPDateTime when)
          Tests if this date is before the given date.
 int compareTo(java.lang.Object obj)
          Compare two XPDateTime objects; Return 0 if the argument Date is equal to this Date, a value less than 0 if this Date is before the Date argument, and a value greater than 0 if this Date is after the Date argument.
 int CompareTo(java.lang.Object obj)
          Compares this object with Object passed to it and returns a value indicating whether one is less than, equal to or greater than the other.
 int CompareTo(XPDateTime date)
          Compare two XPDateTime objects; Return 0 if the argument Date is equal to this Date, a value less than 0 if this Date is before the Date argument, and a value greater than 0 if this Date is after the Date argument.
 boolean equals(java.lang.Object obj)
          false if this Date does not have the same value as the Date argument.
 boolean Equals(XPDateTime date)
          false if this Date does not have the same value as the Date argument.
 long GetTimeInMilliSeconds()
          Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
 java.util.Date GetUnderlyingObject()
          Returns the platform specific object that this class wraps.
 int hashCode()
          Returns the hash code value for this map.
 boolean IsNear(XPDateTime timeToCompare, int withinNumSeconds)
          Determine if this instance date are close to the argument date given a time interval.
 java.lang.String toString()
          Returns the string representation of this object in date/time LONG format based on the runtime locale.
 java.lang.String ToString()
          Returns the string representation of this object in date/time LONG format based on the runtime locale.
 java.lang.String ToString(XPLocale locale)
          Converts the value of this object into it's string representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

dt

protected java.util.Date dt
Internal Date.

Constructor Detail

XPDateTime

public XPDateTime()
Allocates a XPDateTime object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.


XPDateTime

public XPDateTime(long millisecondsSinceEpoch)
Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.

Parameters:
millisecondsSinceEpoch - since January 1, 1970, 00:00:00 GMT.

XPDateTime

public XPDateTime(java.util.Date date)
Allocates a XPDateTime object using the given date value. This method is used by XPCalendar. For this to be a cross-platform compatible usage, the Date argument that is passed in must only be from a call to GetUnderlyingObject() or a corresponding cross-platform method.

Parameters:
date - Java Date
Method Detail

After

public boolean After(XPDateTime when)
Tests if this date is after the given date.

Parameters:
when - Date to be tested.
Returns:
true if and only if the instant represented by this XPDateTime object is strictly later than the instant represented by when; false otherwise.

Before

public boolean Before(XPDateTime when)
Tests if this date is before the given date.

Parameters:
when - Date to be tested.
Returns:
true if and only if the instant of time represented by this XPDateTime object is strictly earlier than the instant represented by when; false otherwise.

GetTimeInMilliSeconds

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

Returns:
the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.

GetUnderlyingObject

public java.util.Date GetUnderlyingObject()
Returns the platform specific object that this class wraps.

Returns:
An instance of Date class

ToString

public java.lang.String ToString(XPLocale locale)
Converts the value of this object into it's string representation.

Parameters:
locale - the locale format to use
Returns:
string representation of this object

ToString

public java.lang.String ToString()
Returns the string representation of this object in date/time LONG format based on the runtime locale.

Returns:
a string representation of this date in date/time LONG format (January 12, 1952, 3:30:32pm) based on the runtime locale (XPLocale.GetDefault()).

toString

public java.lang.String toString()
Returns the string representation of this object in date/time LONG format based on the runtime locale.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this date in date/time LONG format (January 12, 1952, 3:30:32pm) based on the runtime locale (XPLocale.GetDefault()).

CompareTo

public int CompareTo(java.lang.Object obj)
Description copied from interface: IXPComparable
Compares this object with Object passed to it and returns a value indicating whether one is less than, equal to or greater than the other.

Specified by:
CompareTo in interface IXPComparable
Parameters:
obj - object to compare
Returns:
int value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.
See Also:
IXPComparable.CompareTo(Object)

CompareTo

public int CompareTo(XPDateTime date)
Compare two XPDateTime objects; Return 0 if the argument Date is equal to this Date, a value less than 0 if this Date is before the Date argument, and a value greater than 0 if this Date is after the Date argument.

Parameters:
date - to compare with
Returns:
int value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.
See Also:
IXPComparable.CompareTo(Object)

compareTo

public int compareTo(java.lang.Object obj)
Compare two XPDateTime objects; Return 0 if the argument Date is equal to this Date, a value less than 0 if this Date is before the Date argument, and a value greater than 0 if this Date is after the Date argument.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - to compare with
Returns:
int value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.
See Also:
Comparable.compareTo(Object)

IsNear

public boolean IsNear(XPDateTime timeToCompare,
                      int withinNumSeconds)
Determine if this instance date are close to the argument date given a time interval.

Parameters:
timeToCompare - date to compare with
withinNumSeconds - time interval in second
Returns:
true if the two XPDateTime objects are within the specified time interval, else false
Throws:
XPIllegalArgumentException - if num of second is negative, or the XPDateTime object is null

Equals

public boolean Equals(XPDateTime date)
false if this Date does not have the same value as the Date argument. Use values returned by GetTimeInMilliSeconds to compare the two DateTime objects.

Parameters:
date - to test equals with
Returns:
true if the argument Date is equal to this Date;

equals

public boolean equals(java.lang.Object obj)
false if this Date does not have the same value as the Date argument. Use values returned by GetTimeInMilliSeconds to compare the two DateTime objects Overrides Object Equals method.

Overrides:
equals in class java.lang.Object
Parameters:
obj - to test equals with
Returns:
true if the argument Date is equal to this Date;

hashCode

public int hashCode()
Returns the hash code value for this map.

Overrides:
hashCode in class java.lang.Object
Returns:
int value of the hashcode for this XPDateTime Object


Copyright © 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.