Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.time.Clock;
- import java.time.Instant;
- import java.time.LocalDateTime;
- import java.time.ZoneId;
- import java.time.ZonedDateTime;
- public class App {
- public static void main(String[] args) {
- }
- private static Instant getTodayAtHour(int hour) {
- LocalDateTime todayAtSpecifiedHour = LocalDateTime.now().withHour(hour).withMinute(0).withSecond(0).withNano(0);
- ZonedDateTime dt = todayAtSpecifiedHour.atZone(ZoneId.systemDefault());
- Instant instant = dt.toInstant();
- return instant;
- }
- private static Clock get15hsClock() {
- Clock clock15hs = Clock.fixed(getTodayAtHour(15), ZoneId.systemDefault());
- return clock15hs;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement