public class Date
extends java.lang.Object
| Constructor and Description |
|---|
Date(int day,
int month,
int year)
Initializes the object with the given day, month and year.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getDay()
Returns day of the month, or
0 if date is partial and day is not known. |
int |
getMonth()
Returns month of the year, or
0 if date is partial and month is not known. |
int |
getYear()
Returns full year.
|
static Date |
parseFromString(java.lang.String dateString,
java.lang.String pattern)
Creates
Date instance by parsing the given dateString, by using the given
pattern which describes the date format. |
java.lang.String |
toString() |
public Date(int day,
int month,
int year)
day - Day of the month. The first day of the month has value 1.month - Month of the year. The first month of the year has value 1.year - Full year.public int getDay()
0 if date is partial and day is not known.0 if date is partial and day is not known.
The first day of the month has value 1.public int getMonth()
0 if date is partial and month is not known.0 if date is partial and month is not known.
The first month of the year has value 1.public int getYear()
@Nullable public static Date parseFromString(@NonNull java.lang.String dateString, @NonNull java.lang.String pattern)
Date instance by parsing the given dateString, by using the given
pattern which describes the date format.dateString - A String whose beginning should be parsed.pattern - the pattern describing the date format, formatting is the same as in
SimpleDateFormat.Date instance, or null if the dateString
cannot be parsed.java.lang.IllegalArgumentException - if the given pattern is invalid@NonNull public java.lang.String toString()
toString in class java.lang.Object