public class DateAndTime extends java.lang.Object implements java.lang.Comparable, Immutable
This class is designed as a simpler alternative to Date,
which has a number of problems and inconveniences.
Copyright 1997-2006 Partner Software, Inc.
| Modifier and Type | Field and Description |
|---|---|
static java.text.DateFormat |
format |
static java.lang.String |
formatPattern
SimpleDateFormat pattern used by formatPattern |
static java.text.DateFormat |
safeFormat |
static java.lang.String |
safeFormatPattern
SimpleDateFormat pattern used by safeFormat |
static java.lang.String |
twentyFourHourFormatPattern
SimpleDateFormat using 0-23 as hours and including milliseconds |
| Constructor and Description |
|---|
DateAndTime()
Creates a new DateAndTime corresponding to the current date and time.
|
DateAndTime(java.util.Date dateAndTime)
Creates a new DateAndTime from the given java.util.Date object.
|
DateAndTime(long millis)
Creates a new DateAndTime for the given milliseconds since the epoc (same
as java.util.Date convention).
|
DateAndTime(java.lang.String dateAndTimeString)
Creates a new DateAndTime from the given String.
|
DateAndTime(java.sql.Timestamp dateAndTime)
Creates a new DateAndTime from the given java.sql.Timestamp object.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(java.lang.Object nother) |
boolean |
equals(java.lang.Object nother)
Casts passed object to DateAndTime and compares to this object.
|
java.lang.String |
format(java.lang.String formatString)
Format this DateAndTime as a String using the usual Java SimpleDateFormat syntax.
|
Date |
getDate()
Returns the date portion of this DateAndTime.
|
long |
getMillis()
Returns the internal millisecond representation (same format
java.util.Date uses).
|
Time |
getTime()
Returns the time portion of this DateAndTime.
|
java.sql.Date |
toJavaSqlDate() |
java.sql.Timestamp |
toJavaSqlTimestamp() |
java.util.Date |
toJavaUtilDate()
A normal
Date object representing this DateAndTime. |
java.lang.String |
toSafeString()
Returns a filename-safe string.
|
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String formatString)
Returns a String in the specific format representing the Date.
|
public static final java.lang.String twentyFourHourFormatPattern
SimpleDateFormat using 0-23 as hours and including millisecondspublic static final java.lang.String formatPattern
SimpleDateFormat pattern used by formatPatternpublic static final java.text.DateFormat format
public static final java.lang.String safeFormatPattern
SimpleDateFormat pattern used by safeFormatpublic static final java.text.DateFormat safeFormat
public DateAndTime()
public DateAndTime(long millis)
public DateAndTime(java.lang.String dateAndTimeString)
dateAndTimeString - java.lang.IllegalArgumentException - if it can't parse the input.public DateAndTime(java.util.Date dateAndTime)
dateAndTime - a java.util.Date representing the desired date and time.public DateAndTime(java.sql.Timestamp dateAndTime)
dateAndTime - a java.sql.Timestamp representing the desired date and time.public java.util.Date toJavaUtilDate()
Date object representing this DateAndTime.public Date getDate()
public Time getTime()
public long getMillis()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String formatString)
public boolean equals(java.lang.Object nother)
equals in class java.lang.Objectpublic int compareTo(java.lang.Object nother)
compareTo in interface java.lang.Comparablepublic java.lang.String format(java.lang.String formatString)
formatString - public java.sql.Timestamp toJavaSqlTimestamp()
public java.sql.Date toJavaSqlDate()
public java.lang.String toSafeString()