Skip to content

Commit ab812a8

Browse files
committed
Added a date time check example
1 parent 50f30e7 commit ab812a8

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/main/java/nl/rdb/java_examples/datetime/DateTimeExample.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class DateTimeExample {
2020

2121
@Example
2222
void dateTime() {
23-
LocalDateTime dateTime = LocalDateTime.of(2018, 11, 02, 12, 32, 22, 300);
23+
LocalDateTime dateTime = LocalDateTime.of(2018, 11, 2, 12, 32, 22, 300);
2424
log.info(dateTime.toLocalTime().toString());
2525
}
2626

@@ -72,6 +72,17 @@ record Test(LocalDateTime start, LocalDateTime end) {}
7272
.forEach(v -> log.info("{}", v));
7373
}
7474

75+
@Example
76+
void isAfterCheck() {
77+
LocalDateTime start = LocalDateTime.now().plusDays(1).toLocalDate().atStartOfDay();
78+
LocalDateTime end1 = start.plusHours(1);
79+
LocalDateTime end2 = LocalDateTime.now().plusDays(1).toLocalDate().atStartOfDay();
80+
81+
log.info("Is end1 after {}", end1.isAfter(start) ? "Yes" : "No");
82+
log.info("Is end2 after {}", end2.isAfter(start) ? "Yes" : "No");
83+
log.info("Is end2 equal {}", end2.isEqual(start) ? "Yes" : "No");
84+
}
85+
7586
private List<LocalDateTime> countBusinessDays(LocalDateTime startDate, LocalDateTime endDate) {
7687
// Predicate 2: Is a given date is a weekday
7788
Predicate<LocalDateTime> isWeekend = date -> date.getDayOfWeek() == DayOfWeek.SATURDAY

0 commit comments

Comments
 (0)