com.starteam.util
Class Date

java.lang.Object
  extended by com.starteam.util.Date
All Implemented Interfaces:
java.io.Serializable

public final class Date
extends java.lang.Object
implements java.io.Serializable

An SDK implementation of Date which closely mirrors java.util.GregorianCalendar but only supports day, month and year Note that, unlike the Microsoft.NET System.DateTime, the values for Month range from 0 (January) to 11 (December) This is in keeping with java.util.Date and java.util.GregorianCalendar

See Also:
Serialized Form

Field Summary
static int DATE_VALUE_NOT_SET
          Constant used in some properties to indicate this date value has not been set.
static Date MAX_VALUE
          11:59:59 P.M., December 31, 4636 A.D.
static Date MIN_VALUE
          Jan 1, 1900 AD 12:00:00
static Date VALUE_NOT_SET
          Date used in some properties to indicate this date value has not been set.
 
Constructor Summary
Date()
          Creates a new Date using current time in GMT.
Date(int year, int month, int dayOfMonth)
          Create a new Date from a Year, Month and DayOfMonth
Date(java.lang.String s)
          Constructs a Date from a string specified in the standard SQL format i.e.
 
Method Summary
 Date addDays(int nDays)
          Returns a new Date that is nDays after this one.
 int compareTo(Date date)
          Returns: > 0 if this date is after the given date; 0 if this date is the same as the given date; < 0 if this date is before the given date.
 int diffInDays(Date other)
          Subtracts a date from this one, returning the difference in days.
 boolean equals(java.lang.Object other)
          returns true if the content of this Date Object is equal to the specified other instance false if its not, or if the other object is not a Date instance
 int getDayOfMonth()
          returns the day of month (a valid integer between 1 and 31)
 java.lang.String getDebugString()
          a string representation of the content of this object instance generally useful for debugging
static TimeSpan getElapsedTime(Date before, Date after)
          Returns the elapsed time between two Date instances.
 int getMonth()
          returns the month (an integer between 0 and 11)
 int getYear()
          returns the year (an integer between 1900 and 9999)
 int hashCode()
          Returns a hashCode value for the object.
 boolean isAfter(Date date)
          Returns true if the given date is after this one in time
 boolean isBefore(Date date)
          Returns true if the given date is before this one in time
 boolean isEqualTo(Date date)
          Returns true if the given date is the same as this one
 DateTime toDateTime()
          returns a DateTime instance of this date centered at UTC noon
static Date today()
          returns the Date value of today using current time in GMT
 java.lang.String toLocalString(int dateFormat)
          returns a String representation of this Date instance formatted for the default locale
 java.lang.String toSQLString()
          Returns the date in the standard 'SQL' format, i.e.
 java.lang.String toString()
          Returns the date in the standard 'SQL' format, i.e.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final Date MIN_VALUE
Jan 1, 1900 AD 12:00:00


MAX_VALUE

public static final Date MAX_VALUE
11:59:59 P.M., December 31, 4636 A.D. (C.E.)


DATE_VALUE_NOT_SET

public static final int DATE_VALUE_NOT_SET
Constant used in some properties to indicate this date value has not been set.

See Also:
Constant Field Values

VALUE_NOT_SET

public static final Date VALUE_NOT_SET
Date used in some properties to indicate this date value has not been set.

Constructor Detail

Date

public Date(int year,
            int month,
            int dayOfMonth)
Create a new Date from a Year, Month and DayOfMonth

Parameters:
year - 1900 - 9999
month - 0 - 11
dayOfMonth - 1 - 31

Date

public Date()
Creates a new Date using current time in GMT.


Date

public Date(java.lang.String s)
Constructs a Date from a string specified in the standard SQL format i.e. 'yyyy-mm-dd', e.g. "2005-01-28", where 01=January thru 12=December

Parameters:
s - a string specified in the standard SQL format
Method Detail

today

public static Date today()
returns the Date value of today using current time in GMT

Returns:
the Date value of today using current time in GMT

getDayOfMonth

public int getDayOfMonth()
returns the day of month (a valid integer between 1 and 31)

Returns:
int the day of month

getMonth

public int getMonth()
returns the month (an integer between 0 and 11)

Returns:
int the month

getYear

public int getYear()
returns the year (an integer between 1900 and 9999)

Returns:
int the year

toString

public java.lang.String toString()
Returns the date in the standard 'SQL' format, i.e. 'yyyy-mm-dd', e.g. "2005-01-28", where 01=January thru 12=December Note also that the String representation of the date displays months between 1 and 12, whereas the constructor expects months to be described between 0 and 11.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of a date in standard 'SQL' format

toSQLString

public java.lang.String toSQLString()
Returns the date in the standard 'SQL' format, i.e. 'yyyy-mm-dd', e.g. "2005-01-28", where 01=January thru 12=December Note also that the String representation of the date displays months between 1 and 12, whereas the constructor expects months to be described between 0 and 11.

Returns:
the string representation of a date in standard 'SQL' format

toLocalString

public java.lang.String toLocalString(int dateFormat)
returns a String representation of this Date instance formatted for the default locale

Parameters:
dateFormat - a date format descriptor
Returns:
a String representation of this DateTime instance formatted for the default locale

getDebugString

public java.lang.String getDebugString()
a string representation of the content of this object instance generally useful for debugging

Returns:
a string representation of the content of this object instance

equals

public boolean equals(java.lang.Object other)
returns true if the content of this Date Object is equal to the specified other instance false if its not, or if the other object is not a Date instance

Overrides:
equals in class java.lang.Object
Parameters:
other - - the other Date instance
Returns:
true if this date is equal to the other Date

hashCode

public int hashCode()
Returns a hashCode value for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hashCode value for the object.

addDays

public Date addDays(int nDays)
Returns a new Date that is nDays after this one.

Parameters:
nDays - - the number of days to add
Returns:
a new date

diffInDays

public int diffInDays(Date other)
Subtracts a date from this one, returning the difference in days.

Parameters:
other - - the Date instance to subtract from this one
Returns:
the difference as a number of days

isBefore

public boolean isBefore(Date date)
Returns true if the given date is before this one in time

Parameters:
date - - the Date instance to compare with this one
Returns:
true if the given date is before this one in time

isAfter

public boolean isAfter(Date date)
Returns true if the given date is after this one in time

Parameters:
date - - the Date instance to compare with this one
Returns:
true if the given date is after this one in time

isEqualTo

public boolean isEqualTo(Date date)
Returns true if the given date is the same as this one

Parameters:
date - - the Date instance to compare with this one
Returns:
true if the given date is the same as this one

compareTo

public int compareTo(Date date)
Returns: > 0 if this date is after the given date; 0 if this date is the same as the given date; < 0 if this date is before the given date.

Parameters:
date - - the Date instance to compare with this one
Returns:
an integer representing the result of the comparison

toDateTime

public DateTime toDateTime()
returns a DateTime instance of this date centered at UTC noon

Returns:
a DateTime instance of this date centered at UTC noon

getElapsedTime

public static TimeSpan getElapsedTime(Date before,
                                      Date after)
Returns the elapsed time between two Date instances.

Parameters:
before - Date
after - Date
Returns:
TimeSpan; the elapsed time between two Date instances.


StarTeam SDK 14.0, Build 21
Copyright © 2003-2012 Borland Software Corporation. All rights reserved.