Skip to content

Instantly share code, notes, and snippets.

@arielsrv
Created February 27, 2020 16:30
Show Gist options
  • Save arielsrv/d6a7844002f12a46ad816f2cca7e2067 to your computer and use it in GitHub Desktop.
Save arielsrv/d6a7844002f12a46ad816f2cca7e2067 to your computer and use it in GitHub Desktop.
timezone overlap
import java.time.ZonedDateTime;
import static java.lang.System.out;
class Program {
public static void main(String[] args) {
ZonedDateTime thisStart = ZonedDateTime.now().plusHours(-4);
ZonedDateTime thisEnd = ZonedDateTime.now().plusHours(-2);
ZonedDateTime otherStart = ZonedDateTime.now().plusHours(-3);
ZonedDateTime otherEnd = ZonedDateTime.now();
out.print(thisStart + " ");
out.println(thisEnd);
out.print(otherStart + " ");
out.println(otherEnd);
if (thisStart.isBefore(otherEnd) && otherStart.isBefore(thisEnd)) {
out.println("Overlapping ...");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment