Exploring the java.
time API
Maurice Naftalin
@mauricenaftalin
Summary
Summary
Core classes
Summary
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
• Creation, field access, adjustment,
comparison, conversion
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
• Creation, field access, adjustment,
comparison, conversion
Illustrated in operations on WorkPeriod
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
• Creation, field access, adjustment,
comparison, conversion
Illustrated in operations on WorkPeriod
• Creation and splitting
What is a WorkPeriod?
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
12:00
15:00
18:00
21:00
What is a WorkPeriod?
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
12:00
15:00
18:00
21:00
What is a WorkPeriod?
1 2
WorkPeriod LocalDateTime
What is a WorkPeriod?
1 2
WorkPeriod LocalDateTime
Duration wpDuration = [Link]([Link](), [Link]());
[Link]
Generating WorkPeriods
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
12:00
15:00
18:00
21:00
Generating WorkPeriods
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
12:00
15:00
18:00
21:00
Generating WorkPeriods
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
24)
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
24)
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate factory methods
LocalDate thur24May2017 = [Link](2018, 5, 24);
24)
of(int year,=int month,
List<WorkPeriod> workPeriods int dayOfMonth)
[Link](thur24May2017, 3);
assertEquals(6, [Link]());
of(int year, Month month, int dayOfMonth)
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate factory methods
LocalDate thur24May2017 = [Link](2018, 5, 24);
24)
of(int year,=int month,
List<WorkPeriod> workPeriods int dayOfMonth)
[Link](thur24May2017, 3);
assertEquals(6, [Link]());
of(int year, Month month, int dayOfMonth)
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
ofEpochDay(long epochDay)
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate factory methods
LocalDate thur24May2017 = [Link](2018, 5, 24);
24)
of(int year,=int month,
List<WorkPeriod> workPeriods int dayOfMonth)
[Link](thur24May2017, 3);
assertEquals(6, [Link]());
of(int year, Month month, int dayOfMonth)
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
ofEpochDay(long epochDay)
[Link]()
ofYearDay(int year, int dayOfYear)
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate factory methods
LocalDate thur24May2017 = [Link](2018, 5, 24);
24)
of(int year,=int month,
List<WorkPeriod> workPeriods int dayOfMonth)
[Link](thur24May2017, 3);
assertEquals(6, [Link]());
of(int year, Month month, int dayOfMonth)
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
ofEpochDay(long epochDay)
[Link]()
ofYearDay(int year, int dayOfYear)
.map(WorkPeriod::getStartTime)
now(), now(ZoneId)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate factory methods
LocalDate thur24May2017 = [Link](2018, 5, 24);
24)
of(int year,=int month,
List<WorkPeriod> workPeriods int dayOfMonth)
[Link](thur24May2017, 3);
assertEquals(6, [Link]());
of(int year, Month month, int dayOfMonth)
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
ofEpochDay(long epochDay)
[Link]()
ofYearDay(int year, int dayOfYear)
.map(WorkPeriod::getStartTime)
now(), now(ZoneId)
.map(LocalDateTime::getDayOfWeek)
.distinct()
now(Clock clock)
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY,
[Link](THURSDAY, FRIDAY, MONDAY),
MONDAY)
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
import static [Link].*;
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY,
[Link](THURSDAY, FRIDAY, MONDAY),
MONDAY)
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
map(LocalDateTime::getDayOfWeek)
LocalDateTime::getDayOfWeek
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
map(LocalDateTime::getDayOfWeek)
LocalDateTime::getDayOfWeek
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
distinct()
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
collect(toList())
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
@Test
public void testGenerateWorkPeriods() {
LocalDate thur24May2017 = [Link](2018, 5, 24);
List<WorkPeriod> workPeriods = [Link](thur24May2017, 3);
assertEquals(6, [Link]());
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
[Link]()
.map(WorkPeriod::getStartTime)
.map(LocalDateTime::getDayOfWeek)
.distinct()
.collect(toList()));
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
@Test LocalDateTime accessor methods
public void testGenerateWorkPeriods()
int {
getDayOfMonth()
LocalDate thur24May2017 = [Link](2018,
DayOfWeek getDayOfWeek() 5, 24);
List<WorkPeriod> workPeriods
int = getDayOfYear()
[Link](thur24May2017, 3);
assertEquals(6, [Link]());
int getHour()
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
int getMinute()
[Link]()
Month getMonth()
.map(WorkPeriod::getStartTime)
int getMonthValue()
.map(LocalDateTime::getDayOfWeek)
int getNano()
.distinct()
int
.collect(toList())); getSecond
} int getYear()
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
@Test LocalDateTime accessor methods
public void testGenerateWorkPeriods()
int {
getDayOfMonth()
LocalDateTime field accessor methods
LocalDate thur24May2017 = [Link](2018,
DayOfWeek getDayOfWeek() 5, 24);
int get(TemporalField)
List<WorkPeriod> workPeriods
int = getDayOfYear()
[Link](thur24May2017, 3);
long
assertEquals(6, [Link]());getLong(TemporalField)
int getHour()
assertEquals([Link](THURSDAY, FRIDAY, MONDAY),
int getMinute()
[Link]()
Month getMonth()
.map(WorkPeriod::getStartTime)
int getMonthValue()
.map(LocalDateTime::getDayOfWeek)
int getNano()
.distinct()
int
.collect(toList())); getSecond
} int getYear()
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
LocalDateTime field accessor methods
int get(TemporalField)
long getLong(TemporalField)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
LocalDateTime field accessor methods
int get(TemporalField)
long getLong(TemporalField)
import static [Link].*;
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
LocalDateTime field accessor methods
int get(TemporalField)
long getLong(TemporalField)
import static [Link].*;
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
LocalDateTime field accessor methods
int get(TemporalField)
long getLong(TemporalField)
import static [Link].*;
[Link]().get(AMPM_OF_DAY)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
LocalDateTime field accessor methods
int get(TemporalField)
long getLong(TemporalField)
import static [Link].*;
[Link]().get(AMPM_OF_DAY)
[Link]().get(DAY_OF_WEEK)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
dayCount)
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
.limit(dayCount)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
.limit(dayCount)
.collect(toList());
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
.limit(dayCount)
.collect(toList());
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
[Link](1)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
[Link](1)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
return [Link](startDate, d -> [Link](1))
[Link](1)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
plusDays(long), plusMonths(long), plusWeeks(long), plusYears(long)
return [Link](startDate, d -> [Link](1))
[Link](1)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
plusDays(long), plusMonths(long), plusWeeks(long), plusYears(long)
return [Link](startDate, d -> [Link](1))
[Link](1)
minusDays(long), minusMonths(long),...
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
plusDays(long), plusMonths(long), plusWeeks(long), plusYears(long)
return [Link](startDate, d -> [Link](1))
[Link](1)
minusDays(long), minusMonths(long),...
plus(long, TemporalUnit), minus(long, TemporalUnit)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
(from JDK source)
public enum ChronoUnit implements TemporalUnit {
NANOS(…),MICROS(…),MILLIS(…),SECONDS(…),MINUTES(…),HOURS(…),…
}
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
plusDays(long), plusMonths(long), plusWeeks(long), plusYears(long)
return [Link](startDate, d -> [Link](1))
[Link](1)
minusDays(long), minusMonths(long),...
plus(long, TemporalUnit), minus(long, TemporalUnit)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
plusDays(long), plusMonths(long), plusWeeks(long), plusYears(long)
return [Link](startDate, d -> [Link](1))
[Link](1)
minusDays(long), minusMonths(long),...
plus(long, TemporalUnit), minus(long, TemporalUnit)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
plusDays(long), plusMonths(long), plusWeeks(long), plusYears(long)
return [Link](startDate, d -> [Link](1))
[Link](1)
minusDays(long), minusMonths(long),...
plus(long, TemporalUnit), minus(long, TemporalUnit)
plus(TemporalAmount), minus(TemporalAmount)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalDate adjustment methods startDate, int dayCount) {
List<LocalDate> generateWorkingDays(LocalDate
plusDays(long), plusMonths(long), plusWeeks(long), plusYears(long)
return [Link](startDate, d -> [Link](1))
[Link](1)
minusDays(long), minusMonths(long),...
plus(long, TemporalUnit), minus(long, TemporalUnit)
plus(TemporalAmount), minus(TemporalAmount)
withDayOfMonth(int), withDayOfYear(int), withMonth(int), withYear(int)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
[Link](1)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
}
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
}
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
} LocalDate accessor methods
int getDayOfMonth()
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
DayOfWeek getDayOfWeek()
return [Link](startDate, d -> [Link](1))
int getDayOfYear()
.filter(Utils::isWorkingDay)
Month getMonth()
int getMonthValue()
int getYear()
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
} LocalDate accessor methods
int getDayOfMonth()
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
DayOfWeek LocalDate
getDayOfWeek()
field accessor methods
return [Link](startDate, d -> [Link](1))
int int getDayOfYear()
get(TemporalField)
.filter(Utils::isWorkingDay)
Month long getMonth()
getLong(TemporalField)
int getMonthValue()
int getYear()
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
}
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
}
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
.limit(dayCount)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
}
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
.limit(dayCount)
.collect(toList());
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
private static boolean isWorkingDay(LocalDate d) {
return [Link]() != [Link] &&
[Link]() != [Link];
}
List<LocalDate> generateWorkingDays(LocalDate startDate, int dayCount) {
return [Link](startDate, d -> [Link](1))
.filter(Utils::isWorkingDay)
.limit(dayCount)
.collect(toList());
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart
amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart
amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0)
0);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart
amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0)
0);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart
amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0)
0);
LocalTime factory methods
of(int hour, int minute)
List<WorkPeriod> generateWorkPeriods(LocalDate
of(int hour, int minute, int second) date, int dayCount) {
of(int hour, int minute,
List<LocalDate> workingDays = int second, int nanoOfSecond)
generateWorkingDays(date, dayCount);
ofNanoOfDay(long nanoOfDay)
return generateWorkPeriods(workingDays, amStart amStart, workPeriodLength,
ofSecondOfDay(long secondOfDay)
now(), now(Clock), now(ZoneId)
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart
amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
workPeriodLength
pmStart, workPeriodLength);
workPeriodLength
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = [Link](3).plusMinutes(30);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
workPeriodLength
pmStart, workPeriodLength);
workPeriodLength
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = [Link](3).plusMinutes(30);
ofHours(3)
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = [Link](3).plusMinutes(30);
ofHours(3)
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = Duration
[Link](3).plusMinutes(30);
ofHours(3)
factory methods
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = Duration [Link](3).plusMinutes(30);
ofHours(3)
factory methods
List<WorkPeriod> generateWorkPeriods(LocalDate
ofDays(long), ofHours(long), date,
ofMinutes(long), ofSeconds(long), int dayCount)
ofMillis(long), {
ofNanos(long)
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = Duration [Link](3).plusMinutes(30);
ofHours(3)
factory methods
List<WorkPeriod> generateWorkPeriods(LocalDate
ofDays(long), ofHours(long), date,
ofMinutes(long), ofSeconds(long), int dayCount)
ofMillis(long), {
ofNanos(long)
List<LocalDate>
of(long, TemporalUnit)workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = Duration [Link](3).plusMinutes(30);
ofHours(3)
factory methods
List<WorkPeriod> generateWorkPeriods(LocalDate
ofDays(long), ofHours(long), date,
ofMinutes(long), ofSeconds(long), int dayCount)
ofMillis(long), {
ofNanos(long)
List<LocalDate>
of(long, TemporalUnit)workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays,
between(Temporal, Temporal) amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = Duration [Link](3).plusMinutes(30);
ofHours(3)
factory methods
List<WorkPeriod> generateWorkPeriods(LocalDate
ofDays(long), ofHours(long), date,
ofMinutes(long), ofSeconds(long), int dayCount)
ofMillis(long), {
ofNanos(long)
List<LocalDate>
of(long, TemporalUnit)workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays,
between(Temporal, Temporal) amStart, workPeriodLength,
from(TemporalAmount) pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = [Link](3).plusMinutes(30);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = [Link](3).plusMinutes(30);
plusMinutes(30)
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek()
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = [Link](3).plusMinutes(30);
plusMinutes(30)
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration adjustment methods
Duration workPeriodLength
plusDays(long), =plusHours(long),
[Link](3).plusMinutes(30);
plusMinutes(30)
plusMinutes(long),
List<WorkPeriod> plusSeconds(long),plusMillis(long),
generateWorkPeriods(LocalDate plusNanos(long)
date, int dayCount) {
minusDays(long), minusHours(long),...
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
plus(Duration), minus(Duration)
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
minus(long, TemporalUnit), plus(long, TemporalUnit)
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
LocalTime amStart = [Link](9, 0);
LocalTime pmStart = [Link](13, 30);
Duration workPeriodLength = [Link](3).plusMinutes(30);
List<WorkPeriod> generateWorkPeriods(LocalDate date, int dayCount) {
List<LocalDate> workingDays = generateWorkingDays(date, dayCount);
return generateWorkPeriods(workingDays, amStart, workPeriodLength,
pmStart, workPeriodLength);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
amStart)
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
amStart)
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
amStart)
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute, int second, int nanoOfSecond)
amStart)
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month, second, int nanoOfSecond)
days) {int dayOfMonth, int hour, int minute, int second)
amStart)
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
amStart)
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
LocalDateTime
of(int thisAmStart
year, Month month, int= dayOfMonth,
[Link](d, amStart)
int hour,amStart);
int minute, int second, int nanoOfSecond)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
LocalDateTime
of(int thisAmStart
year, Month month, int= dayOfMonth,
[Link](d, amStart)
int hour,amStart);
int minute, int second,
second) int nanoOfSecond)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
LocalDateTime
of(int thisAmStart
year, Month month, int= dayOfMonth,
[Link](d, amStart)
int hour,amStart);
minute, int second,
int minute) second) int nanoOfSecond)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
LocalDateTime
of(int thisAmStart
year, Month month, int= dayOfMonth,
[Link](d, amStart)
int hour,amStart);
minute, int second,
int minute) second) int nanoOfSecond)
of(LocalDate date, LocalTime time)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
LocalDateTime
of(int thisAmStart
year, Month month, int= dayOfMonth,
[Link](d, amStart)
int hour,amStart);
minute, int second,
int minute) second) int nanoOfSecond)
of(LocalDate date, LocalTime time)
now(), now(Clock), now(ZoneId)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
LocalDateTime
of(int thisAmStart
year, Month month, int= dayOfMonth,
[Link](d, amStart)
int hour,amStart);
minute, int second,
int minute) second) int nanoOfSecond)
of(LocalDate date, LocalTime time)
now(), now(Clock), now(ZoneId)
ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
LocalDateTime factory methods
List<WorkPeriod> periods = new ArrayList<>();
of(int
for year, int
(LocalDate d : month,
days) {int dayOfMonth, int hour, int minute) second, int nanoOfSecond)
minute, int second)
LocalDateTime
of(int thisAmStart
year, Month month, int= dayOfMonth,
[Link](d, amStart)
int hour,amStart);
minute, int second,
int minute) second) int nanoOfSecond)
of(LocalDate date, LocalTime time)
now(), now(Clock), now(ZoneId)
ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset)
ofInstant(Instant instant, ZoneId zone)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
[Link](new WorkPeriod(thisAmStart, [Link](amDuration)));
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
[Link](new WorkPeriod(thisAmStart, [Link](amDuration)
[Link](amDuration)));
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
[Link](new WorkPeriod(thisAmStart, [Link](amDuration)
[Link](amDuration)));
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
LocalDateTime adjustment methods
for (LocalDate d : days) {
plusDays(long),
LocalDateTime thisAmStart plusHours(long),
= [Link](d, plusMinutes(long),
amStart);
plusSeconds(long),plusMillis(long),
[Link](new WorkPeriod(thisAmStart, plusNanos(long)
[Link](amDuration)));
[Link](amDuration)
minusDays(long), minusHours(long),...
plus(Duration), minus(Duration)
minus(long, TemporalUnit), plus(long, TemporalUnit)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
[Link](new WorkPeriod(thisAmStart, [Link](amDuration)));
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
[Link](new WorkPeriod(thisAmStart, [Link](amDuration)));
LocalDateTime thisPmStart = [Link](d, pmStart);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
[Link](new WorkPeriod(thisAmStart, [Link](amDuration)));
LocalDateTime thisPmStart = [Link](d, pmStart);
[Link](new WorkPeriod(thisPmStart, [Link](pmDuration)));
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
List<WorkPeriod> generateWorkPeriods(List<LocalDate> days, LocalTime amStart, Duration amDuration,
LocalTime pmStart, Duration pmDuration) {
List<WorkPeriod> periods = new ArrayList<>();
for (LocalDate d : days) {
LocalDateTime thisAmStart = [Link](d, amStart);
[Link](new WorkPeriod(thisAmStart, [Link](amDuration)));
LocalDateTime thisPmStart = [Link](d, pmStart);
[Link](new WorkPeriod(thisPmStart, [Link](pmDuration)));
}
return periods;
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
Splitting periods
WorkPeriod p1 = new WorkPeriod(ldt1,ldt2);
Splitting periods
WorkPeriod p1 = new WorkPeriod(ldt1,ldt2);
ldt1 ldt2
p1
Splitting periods
WorkPeriod p1 = new WorkPeriod(ldt1,ldt2);
Optional<WorkPeriod> p2 = [Link](splitTime);
ldt1 ldt2
p1
Splitting periods
WorkPeriod p1 = new WorkPeriod(ldt1,ldt2);
Optional<WorkPeriod> p2 = [Link](splitTime);
ldt1 splitTime ldt2
p1
Splitting periods
WorkPeriod p1 = new WorkPeriod(ldt1,ldt2);
Optional<WorkPeriod> p2 = [Link](splitTime);
ldt1 splitTime ldt2
p1
Splitting periods
WorkPeriod p1 = new WorkPeriod(ldt1,ldt2);
Optional<WorkPeriod> p2 = [Link](splitTime);
ldt1 splitTime ldt2
p1 p2
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
WorkPeriod p = new WorkPeriod(startTime, endTime);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
WorkPeriod p = new WorkPeriod(startTime, endTime);
Optional<WorkPeriod> newPeriod = [Link]();
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
WorkPeriod p = new WorkPeriod(startTime, endTime);
Optional<WorkPeriod> newPeriod = [Link]();
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
WorkPeriod p = new WorkPeriod(startTime, endTime);
Optional<WorkPeriod> newPeriod = [Link]();
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
WorkPeriod p = new WorkPeriod(startTime, endTime);
Optional<WorkPeriod> newPeriod = [Link]();
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
assertEquals([Link](new WorkPeriod(startTime,midnight)), newPeriod);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
WorkPeriod p = new WorkPeriod(startTime, endTime);
Optional<WorkPeriod> newPeriod = [Link]();
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
assertEquals([Link](new WorkPeriod(startTime,midnight)), newPeriod);
assertEquals(new WorkPeriod(midnight, endTime),p);
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
@Test
public void basicSplitTest() {
LocalDateTime startTime = [Link]().atTime(23, 0);
LocalDateTime endTime = [Link]().plusDays(1).atTime(1, 0);
WorkPeriod p = new WorkPeriod(startTime, endTime);
Optional<WorkPeriod> newPeriod = [Link]();
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
assertEquals([Link](new WorkPeriod(startTime,midnight)), newPeriod);
assertEquals(new WorkPeriod(midnight, endTime),p);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
public Optional<WorkPeriod> split(LocalDateTime splitTime) {
if ([Link](splitTime) && [Link](endTime)) {
WorkPeriod newPeriod =
new WorkPeriod(startTime, [Link](startTime, splitTime));
startTime = splitTime;
return [Link](newPeriod);
} else {
return [Link]();
}
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
public Optional<WorkPeriod> split(LocalDateTime splitTime) {
[Link](splitTime) && [Link](endTime)
if ([Link](splitTime) [Link](endTime)) {
WorkPeriod newPeriod =
new WorkPeriod(startTime, [Link](startTime, splitTime));
startTime = splitTime;
return [Link](newPeriod);
} else {
return [Link]();
}
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison
Conversion
public Optional<WorkPeriod> split(LocalDateTime splitTime) {
[Link](splitTime) && [Link](endTime)
if ([Link](splitTime) [Link](endTime)) {
WorkPeriod newPeriod =
new WorkPeriod(startTime, [Link](startTime, splitTime));
startTime = splitTime;
return [Link](newPeriod);
} else {
return [Link]();
}
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion
public Optional<WorkPeriod> split(LocalDateTime splitTime) {
[Link](splitTime) && [Link](endTime)
if ([Link](splitTime) [Link](endTime)) {
WorkPeriod newPeriodLocalDateTime
= comparison methods
new WorkPeriod(startTime, [Link](startTime, splitTime));
isAfter(ChronoLocalDateTime<?>)
startTime = splitTime;
isBefore(ChronoLocalDateTime<?>)
return [Link](newPeriod);
isEqual(ChronoLocalDateTime<?>)
} else {
compareTo(ChronoLocalDateTime<?>)
return [Link]();
}
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion
public WorkPeriod split() {
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
[Link]().atStartOfDay().plusDays(1);
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
return split(midnight);
} return split(midnight);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion
public WorkPeriod split() {
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
[Link]().atStartOfDay().plusDays(1);
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
toLocalDate()
return split(midnight);
} return split(midnight);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion
public WorkPeriod split() {
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
[Link]().atStartOfDay().plusDays(1);
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
toLocalDate()
return split(midnight);
} return split(midnight);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion toLocalDate()
public WorkPeriod split() {
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
[Link]().atStartOfDay().plusDays(1);
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight);
} return split(midnight);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion toLocalDate()
public WorkPeriod split() {
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
[Link]().atStartOfDay().plusDays(1);
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight);
} return split(midnight);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
public WorkPeriod split() { Conversion methods
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
[Link]().atStartOfDay().plusDays(1);
LocalDateTime midnight = [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight);
} return split(midnight);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
public WorkPeriod split() { Conversion methods
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
toLocalDate()
[Link]().atStartOfDay().plusDays(1);
LocalDateTime ->midnight
LocalDateTime LocalDate/Time
= [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight); toLocalTime()
} return split(midnight);
}
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
public WorkPeriod split() { Conversion methods
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
toLocalDate()
[Link]().atStartOfDay().plusDays(1);
LocalDateTime ->midnight
LocalDateTime LocalDate/Time
= [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight); toLocalTime()
} return split(midnight); atStartOfDay()
}
LocalDate -> LocalDateTime atTime(int hour, int minute, int second, int nanos)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
public WorkPeriod split() { Conversion methods
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
toLocalDate()
[Link]().atStartOfDay().plusDays(1);
LocalDateTime ->midnight
LocalDateTime LocalDate/Time
= [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight); toLocalTime()
} return split(midnight); atStartOfDay()
} atTime(int hour, int minute, int second)
LocalDate -> LocalDateTime atTime(int hour, int minute, int second, int nanos)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
public WorkPeriod split() { Conversion methods
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
toLocalDate()
[Link]().atStartOfDay().plusDays(1);
LocalDateTime ->midnight
LocalDateTime LocalDate/Time
= [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight); toLocalTime()
} return split(midnight); atStartOfDay()
} atTime(int hour, int minute, int second)
LocalDate -> LocalDateTime atTime(int hour, int minute)
minute, int second, int nanos)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
public WorkPeriod split() { Conversion methods
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
toLocalDate()
[Link]().atStartOfDay().plusDays(1);
LocalDateTime ->midnight
LocalDateTime LocalDate/Time
= [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight); toLocalTime()
} return split(midnight); atStartOfDay()
} atTime(int hour, int minute, int second)
LocalDate -> LocalDateTime atTime(int hour, int minute)
minute, int second, int nanos)
atTime(LocalTime)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
public WorkPeriod split() { Conversion methods
public Optional<WorkPeriod>
LocalDateTime midnight = split() {
toLocalDate()
[Link]().atStartOfDay().plusDays(1);
LocalDateTime ->midnight
LocalDateTime LocalDate/Time
= [Link]().plusDays(1).atStartOfDay();
toLocalDate() atStartOfDay()
return split(midnight); toLocalTime()
} return split(midnight); atStartOfDay()
} atTime(int hour, int minute, int second)
LocalDate -> LocalDateTime atTime(int hour, int minute)
minute, int second, int nanos)
atTime(LocalTime)
LocalTime -> LocalDateTime atDate(LocalDate)
The [Link] API — examples
LocalTime LocalDate LocalDateTime Duration
Creation of(int,int) of(int,int,int) of(LocalDate,LocalTime) ofHours(long)
Field access getDayOfWeek() getDayOfWeek() plusMinutes(long)
Adjustment plusDays(long) plus(Duration)
Comparison isBefore(ChronoLocalDateTime)
Conversion atStartOfDay() toLocalDate()
Splitting a non-
empty WorkPeriod
Splitting a non-
empty WorkPeriod
In the demo for this module, we’ll see
Splitting a non-
empty WorkPeriod
In the demo for this module, we’ll see
Splitting a non-
• a demo class with a main method that
empty WorkPeriod creates a WorkPeriod containing three
tasks
In the demo for this module, we’ll see
Splitting a non-
• a demo class with a main method that
empty WorkPeriod creates a WorkPeriod containing three
tasks
• how to write the method that splits the
WorkPeriod
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
12:00
answer urgent e-mail 1:00
write deployment report 4:00
15:00
plan security config 4:00
18:00
21:00
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
12:00
answer urgent e-mail 1:00
write deployment report 4:00
15:00
plan security config 4:00
18:00
21:00
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
12:00
answer urgent e-mail 1:00
write deployment report 4:00
15:00
plan security config 4:00
18:00
21:00
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
Answer urgent e-mail
12:00
Write deployment report answer urgent e-mail 1:00
write deployment report 4:00
15:00
plan security config 4:00
Plan security configuration
18:00
21:00
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
Answer urgent e-mail
12:00
Write deployment report answer urgent e-mail 1:00
write deployment report 4:00
15:00
plan security config 4:00
Plan security configuration
18:00
21:00
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
Answer urgent e-mail
Write deployment report
(1 of 2)
12:00
answer urgent e-mail 1:00
Write deployment report
(2 of 2) write deployment report 4:00
15:00
plan security config 4:00
Plan security configuration
18:00
21:00
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
Answer urgent e-mail
Write deployment report
(1 of 2)
12:00
answer urgent e-mail 1:00
Write deployment report write deployment report 4:00
(2 of 2)
15:00
plan security config 4:00
Plan security configuration
18:00
21:00
A Task Scheduler
6:00
Tue May 22 Wed May 23 Thu May 24
9:00
Answer urgent e-mail
Write deployment report
(1 of 2)
12:00
answer urgent e-mail 1:00
Write deployment report write deployment report 4:00
(2 of 2)
15:00
plan security config 4:00
Plan security configuration
18:00
21:00
What is a WorkPeriod?
1 2
WorkPeriod LocalDateTime
What is a WorkPeriod?
2
LocalDateTime
1
WorkPeriod
What is a WorkPeriod?
2
LocalDateTime
1
WorkPeriod
Task
What is a WorkPeriod?
2
LocalDateTime
1
WorkPeriod
TaskPart Task
What is a WorkPeriod?
2
LocalDateTime
1
WorkPeriod
TaskPart Task
* 1
What is a WorkPeriod?
2
LocalDateTime
1
WorkPeriod
1
* TaskPart Task
* 1
Splitting a task-containing period
LocalDate may22 = [Link](2018,[Link],22);
LocalDateTime startTime = [Link](may22,[Link](9,0));
WorkPeriod p1 = new WorkPeriod(startTime,[Link]([Link](3));
9:00 12:00
Splitting a task-containing period
LocalDate may22 = [Link](2018,[Link],22);
LocalDateTime startTime = [Link](may22,[Link](9,0));
WorkPeriod p1 = new WorkPeriod(startTime,[Link]([Link](3));
[Link](…); [Link](…); ...
9:00 12:00
Task 1 part 1 Task 2 part 1 Task 3 part 1 Task 4 part 1 Task 5 part 1
Splitting a task-containing period
LocalDate may22 = [Link](2018,[Link],22);
LocalDateTime startTime = [Link](may22,[Link](9,0));
WorkPeriod p1 = new WorkPeriod(startTime,[Link]([Link](3));
[Link](…); [Link](…); ...
LocalDateTime splitTime = [Link]([Link](90));
9:00 10:30 12:00
Task 1 part 1 Task 2 part 1 Task 3 part 1 Task 4 part 1 Task 5 part 1
Using NavigableMap
NavigableMap<LocalDateTime,TaskPart> timeToTaskPart;
Using NavigableMap
NavigableMap<LocalDateTime,TaskPart> timeToTaskPart;
keys values
2018-05-22T09:00 Task 1 part 1
2018-05-22T09:40 Task 2 part 1
2018-05-22T10:15 Task 3 part 1
2018-05-22T10:45 Task 4 part 1
2018-05-22T11:20 Task 5 part 1
Using NavigableMap
NavigableMap<LocalDateTime,TaskPart> timeToTaskPart;
keys values
2018-05-22T09:00 Task 1 part 1
2018-05-22T09:40 Task 2 part 1
2018-05-22T10:15 Task 3 part 1
2018-05-22T10:30
2018-05-22T10:45 Task 4 part 1
2018-05-22T11:20 Task 5 part 1
Using NavigableMap
NavigableMap<LocalDateTime,TaskPart> timeToTaskPart;
keys values
2018-05-22T09:00 Task 1 part 1 [Link](
2018-05-22T10:30)
2018-05-22T09:40 Task 2 part 1
2018-05-22T10:15 Task 3 part 1
2018-05-22T10:30
2018-05-22T10:45 Task 4 part 1
2018-05-22T11:20 Task 5 part 1
Using NavigableMap
NavigableMap<LocalDateTime,TaskPart> timeToTaskPart;
keys values
2018-05-22T09:00 Task 1 part 1 [Link](
2018-05-22T10:30)
2018-05-22T09:40 Task 2 part 1
2018-05-22T10:15 Task 3 part 1
2018-05-22T10:30 [Link](
2018-05-22T10:45 Task 4 part 1 2018-05-22T10:30)
2018-05-22T11:20 Task 5 part 1
Using NavigableMap
NavigableMap<LocalDateTime,TaskPart> timeToTaskPart;
keys values
2018-05-22T09:00 Task 1 part 1 [Link](
[Link](
2018-05-22T10:30)
2018-05-22T10:30)
2018-05-22T09:40 Task 2 part 1
2018-05-22T10:15 Task 3 part 1
2018-05-22T10:30 [Link](
2018-05-22T10:45 Task 4 part 1 2018-05-22T10:30)
2018-05-22T11:20 Task 5 part 1
Splitting a task-containing period
WorkPeriod p2 = [Link](splitTime);
9:00 10:30 12:00
Task 1 part 1 Task 2 part 1 Task 3 part 1 Task 4 part 1 Task 5 part 1
Splitting a task-containing period
WorkPeriod p2 = [Link](splitTime);
9:00 10:30 12:00
p2 Task 1 part 1 Task 2 part 1 Task 3 part 1 Task 4 part 1 Task 5 part 1
p1
Splitting a task-containing period
WorkPeriod p2 = [Link](splitTime);
9:00 10:30 12:00
Task 1 part 1 Task 2 part 1 Task 3 part 1
Task 4 part 1 Task 5 part 1
Splitting a task-containing period
WorkPeriod p2 = [Link](splitTime);
9:00 10:30 12:00
Task 1 part 1 Task 2 part 1 Task 3 part 1
Task 4 part 1 Task 5 part 1
Splitting a task-containing period
WorkPeriod p2 = [Link](splitTime);
9:00 10:30 12:00
Task 1 part 1 Task 2 part 1 T3part1 T3part2
Task 4 part 1 Task 5 part 1
Splitting a task-containing period
WorkPeriod p2 = [Link](splitTime);
9:00 10:30 12:00
Task 1 part 1 Task 2 part 1 T3part1
T3part2 Task 4 part 1 Task 5 part 1
Summary
Summary
Core classes
Summary
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
• Creation, field access, adjustment,
comparison, conversion
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
• Creation, field access, adjustment,
comparison, conversion
Illustrated in operations on WorkPeriod
Core classes
• LocalDateTime, LocalDate,
LocalTime, Duration
Summary Core class methods
• Creation, field access, adjustment,
comparison, conversion
Illustrated in operations on WorkPeriod
• Creation and splitting