Last active
November 18, 2020 21:00
-
-
Save kommradHomer/e931a43b19d01fe33fa663583e9d8576 to your computer and use it in GitHub Desktop.
previous midnight timezones
This file contains hidden or 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.koomho.datetime_test; | |
import java.time.LocalDateTime; | |
import java.time.ZoneId; | |
import java.time.ZoneOffset; | |
import java.time.ZonedDateTime; | |
import java.time.format.DateTimeFormatter; | |
import java.util.Arrays; | |
import java.util.Date; | |
import java.util.HashSet; | |
import java.util.Set; | |
import java.util.TimeZone; | |
public class App { | |
public static void main(String[] args) { | |
ZonedDateTime previousFlatHourInUTC=ZonedDateTime.now() | |
.withZoneSameInstant(ZoneOffset.UTC) | |
.withMinute(0) | |
.withSecond(0); | |
//TRAVERSING THE TIMEZONES | |
ZoneId.getAvailableZoneIds().parallelStream().forEach(zoneId -> { | |
if(previousFlatHourInUTC.withZoneSameInstant(ZoneId.of(zoneId)).getHour() ==0) | |
System.out.println("PASSED MIDNIGHT at:"+zoneId); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment