public final class YearMonthDayInterval extends Object implements Serializable
null
and start date must be before or the same date as
the end date.Constructor and Description |
---|
YearMonthDayInterval(Calendar start,
Calendar end) |
YearMonthDayInterval(Date start,
Date end) |
YearMonthDayInterval(String interval)
Constructs a YearMonthDayInterval out of a string.
|
YearMonthDayInterval(YearMonthDay start,
YearMonthDay end) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Date date)
Whether the date falls between this interval
(inclusive endpoints).
|
boolean |
contains(YearMonthDay ymd)
Whether the YearMonthDay falls between this interval
(inclusive endpoints).
|
int |
getDays()
Gets the number of days between start and end dates, rounded down.
|
YearMonthDay |
getEnd() |
Date |
getEndDate() |
Date |
getEndDateEndOfDay()
Gets the end date as midnight the day after to ensure all dates on the
same day as this YearMonthDay are smaller than this returned
exclusive date.
|
int |
getMonths()
Gets the number of months between start and end dates, rounded down.
|
YearMonthDay |
getStart() |
Date |
getStartDate() |
int |
getYears()
Gets the number of years between start and end dates, rounded down.
|
String |
toString()
Gets the interval as a string of this format:
yyyy-MM-dd - yyyy-MM-dd ; |
public YearMonthDayInterval(YearMonthDay start, YearMonthDay end)
public YearMonthDayInterval(String interval)
yyyy-MM-dd - yyyy-MM-dd
, but any
characters in between the start and end are accepted as long as there
is a space after the start YearMontDay and before the end YearMonthDay.interval
- the interval to parsepublic YearMonthDay getStart()
public Date getStartDate()
public YearMonthDay getEnd()
public Date getEndDate()
public Date getEndDateEndOfDay()
public boolean contains(YearMonthDay ymd)
ymd
- the YearMonthDaytrue
if YearMonthDay is included in this intervalpublic boolean contains(Date date)
date
- a datetrue
if the date is included in this intervalpublic int getYears()
public int getMonths()
public int getDays()
Copyright © 2008–2021 Norconex Inc.. All rights reserved.