public class SimpleDate extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<SimpleDate>, java.lang.Cloneable
For convenience it also provides some commonly string representations.
Modifier and Type | Field and Description |
---|---|
protected static java.text.SimpleDateFormat |
BRITISH_FORMAT |
protected static java.text.SimpleDateFormat |
GERMAN_FORMAT |
protected static java.text.SimpleDateFormat |
ISO8601_FORMAT |
protected static java.text.SimpleDateFormat |
SORT_FORMAT |
protected static java.text.SimpleDateFormat |
US_FORMAT |
Constructor and Description |
---|
SimpleDate()
Initialize the new instance with default values (i.e.
|
SimpleDate(java.util.Date date)
Initialize the new instance with a standard date object.
|
SimpleDate(java.util.GregorianCalendar gregorianCalendar)
Initialize the new instance with a standard calendar.
|
SimpleDate(int year,
int month,
int day)
Returns a Date object representing the given parameters.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
asBritishString()
Returns the date in the format "dd/MM/yyyy" ("23/11/2002").
|
java.util.Date |
asDate()
Returns this date as Java Date object.
|
java.lang.String |
asGermanString()
Returns the date in the format "dd.MM.yyyy" ("23.11.2002").
|
java.lang.String |
asISO8601String()
Returns the date in the format "yyyy-MM-dd" ("2002-11-23").
|
java.lang.String |
asSortString()
Returns the date in the format "yyyyMMdd" ("20021123").
|
java.lang.String |
asUSString()
Returns the date in the format "MM/dd/yyyy" ("11/23/2002").
|
java.lang.Object |
clone() |
int |
compareTo(SimpleDate simpleDate) |
boolean |
equals(java.lang.Object object) |
protected java.util.Calendar |
getCalendar() |
int |
getDay()
Returns the day in month as integer (1..31).
|
protected java.util.Date |
getInternalDate() |
int |
getMonth()
Returns the month as integer (1 = January, ..., 12 = December).
|
int |
getYear()
Returns the year as integer (1900..3000).
|
int |
hashCode() |
static SimpleDate |
parseBritishDate(java.lang.String dateString)
Creates a new SimpleDate from the given dateString which must conform to
the format "dd/MM/yyyy".
|
static SimpleDate |
parseGermanDate(java.lang.String dateString)
Creates a new SimpleDate from the given dateString which must conform to
the format "dd.MM.yyyy".
|
static SimpleDate |
parseISO8601Date(java.lang.String dateString)
Creates a new SimpleDate from the given dateString which must conform to
the format "yyyy-MM-dd".
|
static SimpleDate |
parseSortDate(java.lang.String dateString)
Creates a new SimpleDate from the given dateString which must conform to
the format "yyyyMMdd".
|
static SimpleDate |
parseUSDate(java.lang.String dateString)
Creates a new SimpleDate from the given dateString which must conform to
the format "MM/dd/yyyy".
|
protected void |
setCalendar(java.util.Calendar newValue) |
protected void |
setInternalDate(java.util.Date date) |
java.lang.String |
toString()
Returns the date in the format "yyyy-MM-dd" ("2002-11-23").
|
protected static final java.text.SimpleDateFormat SORT_FORMAT
protected static final java.text.SimpleDateFormat ISO8601_FORMAT
protected static final java.text.SimpleDateFormat GERMAN_FORMAT
protected static final java.text.SimpleDateFormat BRITISH_FORMAT
protected static final java.text.SimpleDateFormat US_FORMAT
public SimpleDate()
public SimpleDate(java.util.GregorianCalendar gregorianCalendar)
public SimpleDate(java.util.Date date)
public SimpleDate(int year, int month, int day)
year
- The year of the date to createmonth
- The month of the date to create (1-based, 1=January)day
- The day of the date to createpublic static SimpleDate parseSortDate(java.lang.String dateString) throws java.text.ParseException
java.text.ParseException
public static SimpleDate parseGermanDate(java.lang.String dateString) throws java.text.ParseException
java.text.ParseException
public static SimpleDate parseBritishDate(java.lang.String dateString) throws java.text.ParseException
java.text.ParseException
public static SimpleDate parseUSDate(java.lang.String dateString) throws java.text.ParseException
java.text.ParseException
public static SimpleDate parseISO8601Date(java.lang.String dateString) throws java.text.ParseException
java.text.ParseException
public int getYear()
public int getMonth()
public int getDay()
public java.lang.String asSortString()
public java.lang.String asISO8601String()
public java.lang.String asGermanString()
public java.lang.String asBritishString()
public java.lang.String asUSString()
public java.util.Date asDate()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(SimpleDate simpleDate)
compareTo
in interface java.lang.Comparable<SimpleDate>
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
protected java.util.Date getInternalDate()
protected void setInternalDate(java.util.Date date)
protected java.util.Calendar getCalendar()
protected void setCalendar(java.util.Calendar newValue)