Created
February 18, 2024 18:28
-
-
Save ak-git/8b463c6398ea8d3be8fa3e66837bdcf7 to your computer and use it in GitHub Desktop.
Как получить вторую субботу текущего месяца используя Date Time API?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ak.app; | |
import org.junit.jupiter.api.Test; | |
import java.time.DayOfWeek; | |
import java.time.LocalDate; | |
import java.time.temporal.TemporalAdjusters; | |
class SecondSaturdayOfMonth { | |
@Test | |
void secondSaturdayOfMonth() { | |
LocalDate now = LocalDate.now(); | |
LocalDate date = LocalDate.of(now.getYear(), now.getMonth(), 1) | |
.with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY)).with(TemporalAdjusters.next(DayOfWeek.SATURDAY)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment