public final class YearMonthDay extends Object implements Comparable<YearMonthDay>, Serializable
Calendar
, the months are starting
at 1 (January).Constructor and Description |
---|
YearMonthDay()
Constructs a YearMonthDay with the current date.
|
YearMonthDay(Calendar calendar)
Constructs a YearMonthDay from a
Calendar . |
YearMonthDay(Date date)
Constructs a YearMonthDay from a
Date . |
YearMonthDay(int year)
Constructs a YearMonthDay with the specified year.
|
YearMonthDay(int year,
int month)
Constructs a YearMonthDay with the specified year and month.
|
YearMonthDay(int year,
int month,
int day)
Constructs a YearMonthDay with the specified values.
|
YearMonthDay(String date)
Constructs a YearMonthDay from a string of this format:
yyyy-MM-dd . |
Modifier and Type | Method and Description |
---|---|
YearMonthDay |
addDays(int numOfDays)
Adds a number of days to a new created YearMonthDay.
|
YearMonthDay |
addMonths(int numOfMonths)
Adds a number of months to a new created YearMonthDay.
|
YearMonthDay |
addYears(int numOfYears)
Adds a number of years to a new created YearMonthDay.
|
int |
compareTo(YearMonthDay ymd) |
boolean |
contains(Date date)
Whether this YearmMonthDay contains the given
Date (i.e. |
boolean |
equals(Object obj) |
int |
getDay()
Gets the day.
|
int |
getMonth()
Gets the month.
|
int |
getYear()
Gets the year.
|
int |
hashCode() |
boolean |
isAfter(YearMonthDay ymd)
Whether this YearMonthDay represents a date after the given
YearMonthDay.
|
boolean |
isAfterDate(Date date)
Whether this YearMonthDay represents a date after the given
date.
|
boolean |
isBefore(YearMonthDay ymd)
Whether this YearMonthDay represents a date before the given
YearMonthDay.
|
boolean |
isBeforeDate(Date date)
Whether this YearMonthDay represents a date before the given
date.
|
Calendar |
toCalendar()
Converts this YearMonthDay to a
Calendar at midnight. |
Date |
toDate()
Converts this YearMonthDay to a
Date at midnight. |
Date |
toEndOfDayDate()
Gets the date as midnight the day after to represent the end of the
day.
|
long |
toMillis()
Converts this YearMonthDay to the current time as
UTC milliseconds from the epoch.
|
String |
toString()
Converts the YearMonthDay to a string of this format:
yyyy-MM-dd . |
String |
toString(String pattern) |
public YearMonthDay()
public YearMonthDay(int year, int month, int day)
year
- the yearmonth
- the monthday
- the daypublic YearMonthDay(int year, int month)
year
- the yearmonth
- the monthpublic YearMonthDay(int year)
year
- the yearpublic YearMonthDay(Date date)
Date
.date
- a datepublic YearMonthDay(Calendar calendar)
Calendar
.calendar
- a calendar instantpublic YearMonthDay(String date)
yyyy-MM-dd
.date
- a date stringpublic int getYear()
public int getMonth()
public int getDay()
public boolean isBefore(YearMonthDay ymd)
ymd
- the YearMonthDay to evaluatetrue
if beforepublic boolean isBeforeDate(Date date)
date
- the date to evaluatetrue
if beforepublic boolean isAfter(YearMonthDay ymd)
ymd
- the YearMonthDay to evaluatetrue
if afterpublic boolean isAfterDate(Date date)
date
- the date to evaluatetrue
if afterpublic boolean contains(Date date)
Date
(i.e. same
year, month, and day).date
- date to evaluatetrue
if date is containedpublic long toMillis()
public Date toEndOfDayDate()
public YearMonthDay addDays(int numOfDays)
numOfDays
- number of dayspublic YearMonthDay addMonths(int numOfMonths)
numOfMonths
- number of monthspublic YearMonthDay addYears(int numOfYears)
numOfYears
- number of yearspublic Calendar toCalendar()
Calendar
at midnight.public int compareTo(YearMonthDay ymd)
compareTo
in interface Comparable<YearMonthDay>
public String toString()
yyyy-MM-dd
.Copyright © 2008–2021 Norconex Inc.. All rights reserved.