Returns a copy of this Date plus the specified duration.
Returns a copy of this Date plus the specified duration.
dot or bracket is required to prevent confusing compiler.
For example:
Date(2014, 5, 5) + (5 weeks) Date(2014, 5, 5) + 5.weeks Date(2014, 5, 5) + (2 years) Date(2014, 5, 5) + 2.years
Following lines are identical:
Date(2014, 5, 5) + 5 Date(2014, 5, 5) - -5 Date(2014, 5, 5) + 5.days Date(2014, 5, 5) + (5 days) Date(2014, 5, 5) - -5.days Date(2014, 5, 5) - (-5 days) Date(2014, 5, 5).plusDays(5) // Java friendly Date(2014, 5, 5).minusDays(-5) // Java friendly
duration to add, may be negative
new Date object plus the increased duration
Returns a copy of this Date plus the specified number of days.
Returns a copy of this Date plus the specified number of days.
Following lines are identical:
Date(2014, 5, 5) + 5 Date(2014, 5, 5) - -5 Date(2014, 5, 5) + 5.days Date(2014, 5, 5) + (5 days) Date(2014, 5, 5) - -5.days Date(2014, 5, 5) - (-5 days) Date(2014, 5, 5).plusDays(5) // Java friendly Date(2014, 5, 5).minusDays(-5) // Java friendly
the amount of days to add, may be negative
new Date object plus the increased days
calculate the different between this date and that date
calculate the different between this date and that date
Date(2014, 5, 5) - Date(2014, 5, 1) => 4
Returns a copy of this Date minus the specified duration.
Returns a copy of this Date minus the specified duration.
dot or bracket is required to prevent confusing compiler.
For example:
Date(2014, 5, 5) - (5 weeks) Date(2014, 5, 5) - 5.weeks Date(2014, 5, 5) - (2 years) Date(2014, 5, 5) - 2.years
Following lines are identical:
Date(2014, 5, 5) - 5 Date(2014, 5, 5) + -5 Date(2014, 5, 5) - 5.days Date(2014, 5, 5) - (5 days) Date(2014, 5, 5) + -5.days Date(2014, 5, 5) + (-5 days) Date(2014, 5, 5).minusDays(5) // Java friendly Date(2014, 5, 5).plusDays(-5) // Java friendly
duration to minus, may be positive
new Date object minus the decreased duration
Returns a copy of this Date minus the specified number of days.
Returns a copy of this Date minus the specified number of days.
Following lines are identical:
Date(2014, 5, 5) - 5 Date(2014, 5, 5) + -5 Date(2014, 5, 5) - 5.days Date(2014, 5, 5) - (5 days) Date(2014, 5, 5) + -5.days Date(2014, 5, 5) + (-5 days) Date(2014, 5, 5).minusDays(5) // Java friendly Date(2014, 5, 5).plusDays(-5) // Java friendly
the amount of days to minus, may be positive
new Date object minus the decreased days
select the date with backward convention for given holiday.
select the date with backward convention for given holiday.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find nth day of specified month in current year.
For example:
new Date(2014, 5, 5).dayOfMonthInYear(15, Month.SEPTEMBER);
which is identical to
Date(2014, 5, 5).withDayOfYear(15 th day of September)
in Scala
day of next month.
day of next month. A shorthand of
this + (1 month) dayOfMonth (dom)
find day-of-month for the previous month.
find day-of-month for the previous month. A shorthand of
this - (1 month) withDayOfMonth (dom)
Java Friendly. For Scala, it is recommended to use DSL with withDayOfMonth directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfMonth directly.
Find nth occurrence of day-of-week in current month.
For example:
new Date(2014, 5, 5).dayOfWeekInMonth(3, DayOfWeek.FRIDAY);
which is identical to
Date(2014, 5, 5).withDayOfMonth(3 rd Friday)
in Scala
ordinal of the month, from 1 to 5
DayOfWeek
a new copy of the date
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find nth occurrence of day-of-week of specified month in current year.
For example:
new Date(2014, 5, 5).dayOfWeekInYear(2, DayOfWeek.FRIDAY, Month.SEPTEMBER);
which is identical to
Date(2014, 5, 5).withDayOfYear(2 nd Friday of September)
in Scala
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find nth occurrence of day-of-week in current year.
For example:
new Date(2014, 5, 5).dayOfWeekInYear(3, DayOfWeek.FRIDAY);
which is identical to
Date(2014, 5, 5).withDayOfYear(3 rd Friday)
in Scala
an iterable for every day in the month
an iterable for every day in the month
Java Friendly. It is recommended to use daysOfMonth for Scala.
Java Friendly. It is recommended to use daysOfMonth for Scala.
an iterable for every day in the month
an iterable for every day in this week
(week starts on Monday and ends on Sunday according to ISO 8601: http://en.wikipedia.org/wiki/ISO_week_date)
an iterable for every day in this week
(week starts on Monday and ends on Sunday according to ISO 8601: http://en.wikipedia.org/wiki/ISO_week_date)
Java Friendly. It is recommended to use daysOfWeek for Scala.
Java Friendly. It is recommended to use daysOfWeek for Scala.
an iterable for every day in this week
(week starts on Monday and ends on Sunday according to ISO 8601: http://en.wikipedia.org/wiki/ISO_week_date)
an iterable for every day in the year
an iterable for every day in the year
Java Friendly. It is recommended to use daysOfMonth for Scala.
Java Friendly. It is recommended to use daysOfMonth for Scala.
an iterable for every day in the year
first day of current month
first day of current month
shorthand of
shorthand of
dayOfNextMonth(FirstDayOfMonth)
first day of next year
first day of next year
shorthand of
shorthand of
dayOfPreviousMonth(FirstDayOfMonth)
first day of previous year.
first day of previous year. This is different from previousFirstDayOfYear
first day of the year
first day of the year
Java Friendly. For Scala, it is recommended to use DSL with withDayOfMonth directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfMonth directly.
Find first occurrence of day-of-week in current month.
For example:
new Date(2014, 5, 5).firstInMonth(DayOfWeek.FRIDAY);
which is identical to
Date(2014, 5, 5).withDayOfMonth(1 st Friday)
in Scala
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find first day of specified month in current year.
For example:
new Date(2014, 5, 5).firstInYear(Month.SEPTEMBER);
which is identical to
Date(2014, 5, 5).withDayOfYear(1 st day of September)
in Scala
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find first occurrence of day-of-week of specified month in current year.
For example:
new Date(2014, 5, 5).firstInYear(DayOfWeek.FRIDAY, Month.SEPTEMBER);
which is identical to
Date(2014, 5, 5).withDayOfYear(1 st Friday of September)
in Scala
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find first occurrence of day-of-week in current year.
For example:
new Date(2014, 5, 5).firstInYear(DayOfWeek.FRIDAY);
which is identical to
Date(2014, 5, 5).withDayOfYear(1 st Friday)
in Scala
select the date with forward convention for given holiday.
select the date with forward convention for given holiday.
Java Friendly. It is recommended to use > for Scala.
Java Friendly. It is recommended to use > for Scala.
Java Friendly. It is recommended to use < for Scala.
Java Friendly. It is recommended to use < for Scala.
Java Friendly. It is recommended to use >= for Scala.
Java Friendly. It is recommended to use >= for Scala.
Java Friendly. It is recommended to use <= for Scala.
Java Friendly. It is recommended to use <= for Scala.
last day of the month, different month end and leap month are handled properly
last day of the month, different month end and leap month are handled properly
shorthand of
shorthand of
dayOfNextMonth(LastDayOfMonth)
last day of next year.
last day of next year. This is different from nextLastDayOfYear
shorthand of
shorthand of
dayOfPreviousMonth(LastDayOfMonth)
last day of previous year
last day of previous year
last day of the year
last day of the year
Java Friendly. For Scala, it is recommended to use DSL with withDayOfMonth directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfMonth directly.
Find last occurrence of day-of-week in current month.
For example:
new Date(2014, 5, 5).lastInMonth(DayOfWeek.FRIDAY);
which is identical to
Date(2014, 5, 5).withDayOfMonth(lastFriday)
in Scala
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find last day of specified month in current year.
For example:
new Date(2014, 5, 5).lastInYear(Month.SEPTEMBER);
which is identical to
Date(2014, 5, 5).withDayOfYear(lastDay of September)
in Scala
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find last occurrence of day-of-week of specified month in current year.
For example:
new Date(2014, 5, 5).lastInYear(DayOfWeek.FRIDAY, Month.SEPTEMBER);
which is identical to
Date(2014, 5, 5).withDayOfYear(lastFriday of September)
in Scala
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Java Friendly. For Scala, it is recommended to use DSL with withDayOfYear directly.
Find last occurrence of day-of-week in current year.
For example:
new Date(2014, 5, 5).lastInYear(DayOfWeek.FRIDAY);
which is identical to
Date(2014, 5, 5).withDayOfYear(lastFriday)
in Scala
max day of this month, different month lengths and leap month are considered
max day of this month, different month lengths and leap month are considered
max day of this year, leap year is considered
max day of this year, leap year is considered
Java Friendly. it is recommended to use - for Scala.
Java Friendly. it is recommended to use - for Scala.
calculate the different between this date and that date
new Date(2014, 5, 5).minus(new Date(2014, 5, 1)) => 4
Java Friendly. it is recommended to use - for Scala.
Java Friendly. it is recommended to use - for Scala.
Returns a copy of this Date minus the specified number of days.
Following lines are identical:
new Date(2014, 5, 5).minusDays(5); new Date(2014, 5, 5).plusDays(-5);
the amount of days to minus, may be positive
new Date object minus the decreased days
Java Friendly. it is recommended to use - for Scala.
Java Friendly. it is recommended to use - for Scala.
Returns a copy of this Date minus the specified number of months.
Following lines are identical:
new Date(2014, 5, 5).minusMonths(5); new Date(2014, 5, 5).minusMonths(-5);
the amount of months to minus, may be positive
new Date object minus the decreased months
Java Friendly. it is recommended to use - for Scala.
Java Friendly. it is recommended to use - for Scala.
Returns a copy of this Date minus the specified number of weeks.
Following lines are identical:
new Date(2014, 5, 5).minusWeeks(5); new Date(2014, 5, 5).minusWeeks(-5);
the amount of weeks to minus, may be positive
new Date object minus the decreased weeks
Java Friendly. it is recommended to use - for Scala.
Java Friendly. it is recommended to use - for Scala.
Returns a copy of this Date minus the specified number of years.
Following lines are identical:
new Date(2014, 5, 5).minusYears(5); new Date(2014, 5, 5).minusYears(-5);
the amount of years to minus, may be positive
new Date object minus the decreased years
select the date with modified following convention for given holiday.
select the date with modified following convention for given holiday.
select the date with modified preceding convention for given holiday.
select the date with modified preceding convention for given holiday.
Java Friendly. It is recommended to use nextDayOfYear for Scala.
Java Friendly. It is recommended to use nextDayOfYear for Scala.
coming day-of-year excluding this date
Java Friendly. It is recommended to use nextDayOfMonth for Scala.
Java Friendly. It is recommended to use nextDayOfMonth for Scala.
coming day-of-month excluding this date
return the first occurrence of the specified day-of-week after current date:
For example:
Date(2014-07-05).next(Monday) => Date(2014-07-07)
Date(2014-07-05).next(Saturday) => Date(2014-07-12) // note 2014-07-05 itself is already Saturday
return the first occurrence of the specified day-of-week after current date:
For example:
Date(2014-07-05).next(Monday) => Date(2014-07-07)
Date(2014-07-05).next(Saturday) => Date(2014-07-12) // note 2014-07-05 itself is already Saturday
This method is an alias of next(DayOfMonth) for Scala to prevent overloading when using DSL.
This method is an alias of next(DayOfMonth) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).nextDayOfMonth(3 rd Friday)
This method is an alias of next(DayOfYear) for Scala to prevent overloading when using DSL.
This method is an alias of next(DayOfYear) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).nextDayOfYear(3 rd Friday)
shorthand of comingDayOfMonth(FirstDayOfMonth)
For example:
shorthand of comingDayOfMonth(FirstDayOfMonth)
For example:
Date(2014, 7, 31).comingMonthBegin => Date(2014, 8, 1) Date(2014, 8, 1).comingMonthBegin => Date(2014, 9, 1)
shorthand of next(FirstDayOfYear)
For example:
Date(2014, 8, 2).comingYearBegin => Date(2015, 1, 1)
Date(2015, 1, 1).comingYearBegin => Date(2016, 1, 1)
shorthand of next(FirstDayOfYear)
For example:
Date(2014, 8, 2).comingYearBegin => Date(2015, 1, 1)
Date(2015, 1, 1).comingYearBegin => Date(2016, 1, 1)
shorthand of comingDayOfMonth(LastDayOfMonth)
For example:
shorthand of comingDayOfMonth(LastDayOfMonth)
For example:
Date(2014, 7, 30).comingMonthEnd => Date(2014, 7, 31) Date(2014, 7, 31).comingMonthEnd => Date(2014, 8, 31)
Note this is different from lastDayOfNextMonth
shorthand of next(LastDayOfYear).
shorthand of next(LastDayOfYear). For example:
Date(2014, 8, 2).comingYearEnd => Date(2014, 12, 31) Date(2014, 12, 31).comingYearEnd => Date(2015, 12, 31)
Note this is different from lastDayOfNextYear
Java Friendly. It is recommended to use nextOrSameDayOfYear for Scala.
Java Friendly. It is recommended to use nextOrSameDayOfYear for Scala.
coming day-of-year including this date
Java Friendly. It is recommended to use nextOrSameDayOfMonth for Scala.
Java Friendly. It is recommended to use nextOrSameDayOfMonth for Scala.
coming day-of-month including this date
return the first occurrence of the specified day-of-week after current date, unless current date is already on that day.
return the first occurrence of the specified day-of-week after current date, unless current date is already on that day.
For example:
Date(2014-07-05).nextOrSame(Monday) => Date(2014-07-07) Date(2014-07-05).nextOrSame(Saturday) => Date(2014-07-5) // note 2014-07-05 itself is already Saturday
This method is an alias of nextOrSame(DayOfMonth) for Scala to prevent overloading when using DSL.
This method is an alias of nextOrSame(DayOfMonth) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).nextOrSameDayOfMonth(3 rd Friday)
This method is an alias of nextOrSame(DayOfYear) for Scala to prevent overloading when using DSL.
This method is an alias of nextOrSame(DayOfYear) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).nextOrSameDayOfYear(3 rd Friday)
Java Friendly. it is recommended to use + for Scala.
Java Friendly. it is recommended to use + for Scala.
Returns a copy of this Date plus the specified number of days.
Following lines are identical:
new Date(2014, 5, 5).plusDays(5); new Date(2014, 5, 5).minusDays(-5);
the amount of days to add, may be negative
new Date object plus the increased days
Java Friendly. it is recommended to use + for Scala.
Java Friendly. it is recommended to use + for Scala.
Returns a copy of this Date plus the specified number of months.
Following lines are identical:
new Date(2014, 5, 5).plusMonths(5); new Date(2014, 5, 5).minusMonths(-5);
the amount of months to add, may be negative
new Date object plus the increased months
Java Friendly. it is recommended to use + for Scala.
Java Friendly. it is recommended to use + for Scala.
Returns a copy of this Date plus the specified number of weeks.
Following lines are identical:
new Date(2014, 5, 5).plusWeeks(5); new Date(2014, 5, 5).minusWeeks(-5);
the amount of weeks to add, may be negative
new Date object plus the increased weeks
Java Friendly. it is recommended to use + for Scala.
Java Friendly. it is recommended to use + for Scala.
Returns a copy of this Date plus the specified number of years.
Following lines are identical:
new Date(2014, 5, 5).plusYears(5); new Date(2014, 5, 5).minusYears(-5);
the amount of years to add, may be negative
new Date object plus the increased years
Java Friendly. It is recommended to use previousDayOfYear for Scala.
Java Friendly. It is recommended to use previousDayOfYear for Scala.
past day-of-year excluding this date
Java Friendly. It is recommended to use previousDayOfMonth for Scala.
Java Friendly. It is recommended to use previousDayOfMonth for Scala.
past day-of-month excluding this date
previous day-of-week excluding this date.
previous day-of-week excluding this date. For example:
Date(2014-07-05).previous(Monday) => Date(2014-06-30) <br> Date(2014-07-05).previous(Saturday) => Date(2014-06-28) // note 2014-07-05 itself is already Saturday
This method is an alias of previous(DayOfMonth) for Scala to prevent overloading when using DSL.
This method is an alias of previous(DayOfMonth) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).previousDayOfMonth(3 rd Friday)
This method is an alias of previous(DayOfYear) for Scala to prevent overloading when using DSL.
This method is an alias of previous(DayOfYear) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).previousDayOfYear(3 rd Friday)
shorthand of pastDayOfMonth(FirstDayOfMonth)
For example:
shorthand of pastDayOfMonth(FirstDayOfMonth)
For example:
Date(2014, 8, 2).pastMonthBegin => Date(2014, 8, 1) Date(2014, 8, 1).pastMonthBegin => Date(2014, 7, 1)
Note this is different from firstDayOfPreviousMonth
shorthand of previous(FirstDayOfYear).
shorthand of previous(FirstDayOfYear). For example:
Date(2014, 8, 2).previousFirstDayOfYear => Date(2014, 1, 1) Date(2014, 1, 1).previousFirstDayOfYear => Date(2013, 1, 1)
Note this is different from firstDayOfPreviousYear
shorthand of pastDayOfMonth(LastDayOfMonth)
For example:
shorthand of pastDayOfMonth(LastDayOfMonth)
For example:
Date(2014, 8, 5).pastMonthEnd => Date(2014, 7, 31) Date(2014, 7, 31).pastMonthEnd => Date(2014, 6, 30)
shorthand of previous(LastDayOfYear)
For example:
Date(2014, 8, 2).previousLastDayOfYear => Date(2013, 12, 31)
Date(2013, 12, 31).previousLastDayOfYear => Date(2012, 12, 31)
shorthand of previous(LastDayOfYear)
For example:
Date(2014, 8, 2).previousLastDayOfYear => Date(2013, 12, 31)
Date(2013, 12, 31).previousLastDayOfYear => Date(2012, 12, 31)
Java Friendly. It is recommended to use previousOrSameDayOfYear for Scala.
Java Friendly. It is recommended to use previousOrSameDayOfYear for Scala.
past day-of-year including this date
Java Friendly. It is recommended to use previousOrSameDayOfMonth for Scala.
Java Friendly. It is recommended to use previousOrSameDayOfMonth for Scala.
past day-of-month including this date
previous day of week before current date, unless current date is already on specified day-of-week
previous day of week before current date, unless current date is already on specified day-of-week
For example:
Date(2014-07-05).previousOrSame(Monday) => Date(2014-06-30) Date(2014-07-05).previousOrSame(Saturday) => Date(2014-07-05) // note 2014-07-05 itself is already Saturday
This method is an alias of previousOrSame(DayOfMonth) for Scala to prevent overloading when using DSL.
This method is an alias of previousOrSame(DayOfMonth) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).previousOrSameDayOfMonth(3 rd Friday)
This method is an alias of previousOrSame(DayOfYear) for Scala to prevent overloading when using DSL.
This method is an alias of previousOrSame(DayOfYear) for Scala to prevent overloading when using DSL.
Usage example:
Date(2014, 5, 5).previousOrSameDayOfYear(3 rd Friday)
Every day in the same month with same dow
eg, if this.dayOfWeek == Wednesday, then this is a list of all Wednesday in the same month
Every day in the same month with same dow
eg, if this.dayOfWeek == Wednesday, then this is a list of all Wednesday in the same month
Java Friendly. It is recommended to use sameWeekdaysOfMonth for Scala.
Java Friendly. It is recommended to use sameWeekdaysOfMonth for Scala.
Every day in the same month with same dow
eg, if this.dayOfWeek == Wednesday, then this is a list of all Wednesday in the same month
Every day in the same year with same dow
eg, if this.dayOfWeek == Wednesday, then this is a list of all Wednesday in the same year
Every day in the same year with same dow
eg, if this.dayOfWeek == Wednesday, then this is a list of all Wednesday in the same year
Java Friendly. It is recommended to use sameWeekdaysOfYear for Scala.
Java Friendly. It is recommended to use sameWeekdaysOfYear for Scala.
Every day in the same year with same dow
eg, if this.dayOfWeek == Wednesday, then this is a list of all Wednesday in the same year
generate a DateRange iterable, which can be used similar as scala.collection.immutable.Range.
generate a DateRange iterable, which can be used similar as scala.collection.immutable.Range. eg,
both this date and that date included
for (d <- Date(2014, 5, 5) to Date(2014, 5, 10)) println(d)
int representation in yyyyMMdd form
standard ISO string in yyyy-mm-dd.
standard ISO string in yyyy-mm-dd. eg, 2014-05-23 or 2014-11-02
generate a DateRange iterable, which can be used similar as scala.collection.immutable.Range.
generate a DateRange iterable, which can be used similar as scala.collection.immutable.Range. eg,
this date is included but that date isn't
for (d <- Date(2014, 5, 5) until Date(2014, 5, 10)) println(d)
find the day of this month matching specified day-of-month.
find the day of this month matching specified day-of-month. DSL can be used directly.
Usage example:
Date(2014, 5, 5).withDayOfMonth(lastDay) Date(2014, 5, 5).withDayOfMonth(3 rd Friday) Date(2014, 5, 5).withDayOfMonth(20 th day)
find the day of this week matching specified day-of-week
find the day of this week matching specified day-of-week
A week starts with Monday according to ISO8601 http://en.wikipedia.org/wiki/ISO_week_date
find the day of this year matching specified day-of-month.
find the day of this year matching specified day-of-month. DSL can be used directly.
Usage example:
Date(2014, 5, 5).withDayOfYear(lastDay) => Date(2014,12,31) Date(2014, 5, 5).withDayOfYear(3 rd Friday) => Date(2014,1,17) Date(2014, 5, 5).withDayOfYear(20 th day) => Date(2014,1,20) Date(2014, 5, 5).withDayOfYear(2 nd Tuesday of September) => Date(2014,9,9)
immutable object to represent a Date. All mutating operations will return a new Date.