public class Date
extends java.lang.Object
Month.| Modifier and Type | Class and Description |
|---|---|
static class |
Date.Unit
Units to be used in
Date-mathemathics. |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_DATE_FORMAT
A date-format-pattern to be used for formatting, if no other is defined.
|
| Modifier and Type | Method and Description |
|---|---|
Date |
add(long amountToAdd,
Date.Unit unit)
Changes a current value of an object for
amountToAdd units of unit |
int |
compareTo(Date other)
Compares an object with another
Date-object. |
int |
compareTo(DateTime other)
Compares an object with another
DateTime object. |
boolean |
equals(java.lang.Object other)
Compares an object to another
Date object. |
int |
getDay() |
int |
getMonth()
Month is INTENTIONALLY returned as an int, in order to avoid dependency on
Month |
int |
getYear() |
int |
hashCode()
Hashcode of an object.
Hashcode of an object will be a hashcode of its value-container object value |
boolean |
isSameDateAs(DateTime otherDateTime)
|
static Date |
now()
Creating a date with a current
Date value. |
static Date |
of(Date date)
Creating a date from a
Date. |
static Date |
of(DateTime dateTime)
Creating a date from a
DateTime |
static Date |
of(java.time.LocalDate localDate)
Creates a date from a
LocalDate |
Date |
toEndOfYear() |
java.util.Date |
toJavaUtilDate()
Converts an object to
Date. |
java.time.LocalDate |
toLocalDate()
Converts an object to
LocalDate. |
Date |
toStartOfYear() |
java.lang.String |
toString()
Converts to
String, using DEFAULT_FORMATTER. |
static java.lang.String |
toString(Date date,
java.time.format.DateTimeFormatter formatter)
Converts
date to String, using formatter, following all other rules of formatting. |
static java.lang.String |
toString(Date date,
java.util.Locale locale)
Converts
date to String, using locale, following all other rules of formatting. |
static java.lang.String |
toString(Date date,
java.lang.String formatDescription)
Converts
date to String, using formatDescription, following all other rules of formatting. |
java.lang.String |
toString(java.time.format.DateTimeFormatter formatter)
Converts to
String, using formatter. |
java.lang.String |
toString(java.util.Locale locale)
Converts to
String, using locale. |
java.lang.String |
toString(java.lang.String formatDescription)
Converts to
String, using a DateTimeFormatter defined by formatDescription. |
public static final java.lang.String DEFAULT_DATE_FORMAT
public static Date of(java.time.LocalDate localDate)
LocalDatepublic static Date now()
Date value.Date-object.public int getYear()
Date-objectpublic int getMonth()
MonthDate-object.public int getDay()
Date-object.public int compareTo(DateTime other)
DateTime object.
Comparation is made only on an intersected set of attributes for Date and DateTime.other - A comparing objectpublic Date add(long amountToAdd, Date.Unit unit)
amountToAdd units of unitamountToAdd - quantity of unit to be added (or subtracted, if amountToAdd is negative} to a current object.unit - Chrono-unit of measureDate-objectpublic java.time.LocalDate toLocalDate()
LocalDate.LocalDate value of an object.public java.util.Date toJavaUtilDate()
Date.Date value of an object.public java.lang.String toString()
String, using DEFAULT_FORMATTER.toString in class java.lang.Objectpublic java.lang.String toString(java.time.format.DateTimeFormatter formatter)
String, using formatter.
If formatter is null, then a standard toString() is used.formatter - A format to be used when formatting a datepublic java.lang.String toString(java.util.Locale locale)
String, using locale.
If locale is null, then a standard DEFAULT_LOCALE is used.locale - A locale to be used when formatting a datepublic java.lang.String toString(java.lang.String formatDescription)
String, using a DateTimeFormatter defined by formatDescription.formatDescription - A String-definition of a DateTimeFormatter to be used when formatting a datepublic static java.lang.String toString(Date date, java.util.Locale locale)
date to String, using locale, following all other rules of formatting.date - A Date-object that should be converted to a String.locale - A locale to be used when formatting a date.toString(Locale locale)public static java.lang.String toString(Date date, java.lang.String formatDescription)
date to String, using formatDescription, following all other rules of formatting.date - A Date-object that should be converted to a String.formatDescription - A String-definition of a DateTimeFormatter to be used when formatting a date.toString(String formatDescription)public static java.lang.String toString(Date date, java.time.format.DateTimeFormatter formatter)
date to String, using formatter, following all other rules of formatting.date - A Date-object that should be converted to a String.formatter - A format to be used when formatting a date.toString(DateTimeFormatter formatter)public int hashCode()
valuehashCode in class java.lang.Objectpublic boolean equals(java.lang.Object other)
Date object.
Two Date objects will be treated equal, if their value-container objects value are equal.equals in class java.lang.Objecttrue, if objects are equal,false, otherwise.public boolean isSameDateAs(DateTime otherDateTime)
DateTime-object.equals in order to prevent a possible mix-up.Date and DateTime will be treated as "of same date" if they are equal on year/month/dayOfMonth levelotherDateTime - The other objecttrue, if objects are equal on an intersected set of attributesfalse, otherwise.