public final class DateAdjusters extends Object
DateAdjuster
.
DateAdjusters is a utility class. All adjusters returned are immutable and thread-safe.
Modifier and Type | Method and Description |
---|---|
static DateAdjuster |
dayOfWeekInMonth(int ordinal,
DayOfWeek dayOfWeek)
Returns the day-of-week in month adjuster, which returns a new date
in the same month with the ordinal day-of-week.
|
static DateAdjuster |
firstDayOfMonth()
Returns the first day-of-month adjuster, which returns a new date with
the day-of-month changed to be the first day of the month.
|
static DateAdjuster |
firstDayOfYear()
Returns the first day-of-year adjuster, which returns a new date with
the day-of-year changed to be the first day of the year - January 1.
|
static DateAdjuster |
firstInMonth(DayOfWeek dayOfWeek)
Returns the first in month adjuster, which returns a new date
in the same month with the first matching day-of-week.
|
static DateAdjuster |
lastDayOfMonth()
Returns the last day-of-month adjuster, which returns a new date with
the day-of-month changed to be the last valid day of the month.
|
static DateAdjuster |
lastDayOfYear()
Returns the last day-of-year adjuster, which returns a new date with
the day-of-year changed to be the last day of the year - December 31.
|
static DateAdjuster |
next(DayOfWeek dow)
Returns the next day-of-week adjuster, which adjusts the date to be
the next of the specified day-of-week after the specified date.
|
static DateAdjuster |
nextNonWeekendDay()
Returns the next non weekend day adjuster, which adjusts the date one day
forward skipping Saturday and Sunday.
|
static DateAdjuster |
nextOrCurrent(DayOfWeek dow)
Returns the next or current day-of-week adjuster, which adjusts the
date to be be the next of the specified day-of-week, returning the
input date if the day-of-week matched.
|
static DateAdjuster |
previous(DayOfWeek dow)
Returns the previous day-of-week adjuster, which adjusts the date to be
the previous of the specified day-of-week after the specified date.
|
static DateAdjuster |
previousOrCurrent(DayOfWeek dow)
Returns the previous or current day-of-week adjuster, which adjusts the
date to be be the previous of the specified day-of-week, returning the
input date if the day-of-week matched.
|
public static DateAdjuster firstDayOfMonth()
The input 2007-01-15 will return 2007-01-01.
The input 2008-02-15 will return 2008-02-01.
public static DateAdjuster lastDayOfMonth()
The input 2007-01-15 will return 2007-01-31.
The input 2007-02-15 will return 2007-02-28.
The input 2007-03-15 will return 2007-03-31.
The input 2007-04-15 will return 2007-04-30.
The input 2008-02-15 will return 2008-02-29.
public static DateAdjuster firstDayOfYear()
The input 2007-01-15 will return 2007-01-01.
The input 2008-02-15 will return 2008-01-01.
public static DateAdjuster lastDayOfYear()
The input 2007-01-15 will return 2007-12-31.
The input 2008-02-15 will return 2008-12-31.
public static DateAdjuster nextNonWeekendDay()
public static DateAdjuster firstInMonth(DayOfWeek dayOfWeek)
The input 2007-12-15 for (MONDAY) will return 2007-12-03.
The input 2007-12-15 for (TUESDAY) will return 2007-12-04.
dayOfWeek
- the day-of-week, not nullpublic static DateAdjuster dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek)
The input 2007-12-15 for (1,MONDAY) will return 2007-12-03.
The input 2007-12-15 for (2,TUESDAY) will return 2007-12-11.
The input 2007-12-15 for (3,TUESDAY) will return 2007-12-18.
The input 2007-12-15 for (4,TUESDAY) will return 2007-12-25.
The input 2007-12-15 for (5,TUESDAY) will return 2008-01-01.
If the ordinal is 5 and there is no 5th of the requested day-of-week, then the first of the next month is returned.
ordinal
- ordinal, from 1 to 5dayOfWeek
- the day-of-week, not nullIllegalArgumentException
- if the ordinal is invalidpublic static DateAdjuster next(DayOfWeek dow)
dow
- the day-of-week to move the date to, not nullpublic static DateAdjuster nextOrCurrent(DayOfWeek dow)
dow
- the day-of-week to move the date to, not nullpublic static DateAdjuster previous(DayOfWeek dow)
dow
- the day-of-week to move the date to, not nullpublic static DateAdjuster previousOrCurrent(DayOfWeek dow)
dow
- the day-of-week to move the date to, not nullCopyright © 2014. All rights reserved.