2004.04.29


com.jdc.dts
Class Date

java.lang.Object
  |
  +--com.jdc.dts.Date
Direct Known Subclasses:
DateTime

public class Date
extends Object

Class Date represents a date. Date provides operations date manipulation and formatting. Note: Month value is 1-based, not 0-based like the Java Calendar class.

Reference: http://www.javaworld.com/jw-12-2000/jw-1229-dates.html Reference: http://www.onjava.com/pub/a/onjava/2003/06/05/java_calendar.html Reference: http://java.sun.com/docs/books/tutorial/i18n/format/dateintro.html

Version:
1.0
Author:
Jay Damon
See Also:
Calendar, Date

Nested Class Summary
 class Date.Format
          Class Format contains constants representing various date format style patterns.
 
Constructor Summary
Date()
          Constructs a new Date object for the current date and time.
Date(Locale locale)
          Constructs a new Date object for the specified Locale.
 
Method Summary
 String format()
          Returns a formatted String representation of this Date object using the default format.
 String format(int style)
          Returns a formatted String representation of this Date object in the specified style.
 Calendar getCalendar()
          Returns the Java Calendar object for this Date object.
 Date getDate()
          Returns the Java Date object for this Date object.
 int getDay()
          Returns the integer day value this Date object.
 String getMessage()
          Returns the appropriate message text for an invalid date.
 int getMonth()
          Returns the integer month value this Date object.
 long getTime()
          Returns the long value this Date object.
 int getYear()
          Returns the integer year value this Date object.
 int intValue()
          Converts this Date to an int.
 boolean isDate()
          Returns true if the value represented by this Date object is a valid date.
 boolean isValid()
          Returns true if the value represented by this Date object is within a specified date range.
static void main(String[] args)
          Executes the unit tests for the Date class.
 Date set(Calendar calendar)
          Sets the values for this Date object based on a Java Calendar object.
 Date set(Date date)
          Sets the value for this Date object based on a Java Date object.
 Date set(String date)
          Sets the value for this Date object based on a String date value.
 Date setStrict()
          Sets the flag to enforce strict parsing of a String date value.
 String toLongFormat()
          Returns a long format String representation of this Date object.
 String toShortFormat()
          Returns a short format String representation of this Date object.
 String toString()
          Returns a String representation of this Date object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Date

public Date()
Constructs a new Date object for the current date and time.


Date

public Date(Locale locale)
Constructs a new Date object for the specified Locale.

Method Detail

format

public String format()
Returns a formatted String representation of this Date object using the default format.

Returns:
A formatted String representation of this Date object.

format

public String format(int style)
Returns a formatted String representation of this Date object in the specified style.

Returns:
A formatted String representation of this Date object.

getCalendar

public Calendar getCalendar()
Returns the Java Calendar object for this Date object.

Returns:
The Java Calendar object for this Date object.

getDate

public Date getDate()
Returns the Java Date object for this Date object.

Returns:
The Java Date object for this Date object.

getDay

public int getDay()
Returns the integer day value this Date object.

Returns:
The integer day value this Date object.

getMessage

public String getMessage()
Returns the appropriate message text for an invalid date.

Returns:
The appropriate message text for an invalid date.

getMonth

public int getMonth()
Returns the integer month value this Date object.

Returns:
The integer month value this Date object.

getTime

public long getTime()
Returns the long value this Date object.

Returns:
The long value this Date object.

getYear

public int getYear()
Returns the integer year value this Date object.

Returns:
The integer year value this Date object.

intValue

public int intValue()
Converts this Date to an int.

Returns:
The numeric value represented by this object after conversion to type int.

isDate

public boolean isDate()
Returns true if the value represented by this Date object is a valid date.

Returns:
True if the value is a valid date. False if the value is not a valid date.

isValid

public boolean isValid()
Returns true if the value represented by this Date object is within a specified date range.

Returns:
True if the value is within the specified date range. False if the value is not within the specified date range.

set

public Date set(Calendar calendar)
Sets the values for this Date object based on a Java Calendar object.

Returns:
ThisDate object.

set

public Date set(Date date)
Sets the value for this Date object based on a Java Date object.

Returns:
ThisDate object.

set

public Date set(String date)
Sets the value for this Date object based on a String date value.

Returns:
ThisDate object.

setStrict

public Date setStrict()
Sets the flag to enforce strict parsing of a String date value.

Returns:
ThisDate object.

toLongFormat

public String toLongFormat()
Returns a long format String representation of this Date object.

Returns:
A long format String representation of this Datel object.

toShortFormat

public String toShortFormat()
Returns a short format String representation of this Date object.

Returns:
A short format String representation of this Date object.

toString

public String toString()
Returns a String representation of this Date object.

Overrides:
toString in class Object
Returns:
A String representation of this Date object.

main

public static void main(String[] args)
Executes the unit tests for the Date class.


2004.04.29



Copyright © 2004 J. Damon & Co.; All Rights Reserved WorldWide.