Created
March 17, 2023 15:52
-
-
Save alexspurling/8770e32e28aefbcd271f09ed50d30fb3 to your computer and use it in GitHub Desktop.
When did Michael Jackson's hair catch on fire?
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
import java.time.ZoneId; | |
import java.time.ZonedDateTime; | |
import java.time.temporal.ChronoUnit; | |
/* | |
output: | |
Earliest midpoint in LA: 1984-01-26T17:13-08:00[America/Los_Angeles] | |
Latest midpoint in LA: 1984-01-27T05:13-08:00[America/Los_Angeles] | |
*/ | |
public class MJTimes { | |
private static final ZoneId LA = ZoneId.of("America/Los_Angeles"); | |
private static final ZoneId GARY = ZoneId.of("America/Chicago"); | |
public static void main(String[] args) { | |
ZonedDateTime death = ZonedDateTime.of(2009, 6, 25, 14, 26, 0, 0, LA); | |
ZonedDateTime earliestBirth = ZonedDateTime.of(1958, 8, 29, 0, 0, 0, 0, GARY); | |
ZonedDateTime latestBirth = ZonedDateTime.of(1958, 8, 30, 0, 0, 0, 0, GARY); | |
long secondsToEarliestMidpoint = ChronoUnit.SECONDS.between(earliestBirth, death) / 2; | |
long secondsToLatestMidpoint = ChronoUnit.SECONDS.between(latestBirth, death) / 2; | |
ZonedDateTime earliestIndianaMidpoint = earliestBirth.plusSeconds(secondsToEarliestMidpoint); | |
ZonedDateTime latestIndianaMidpoint = latestBirth.plusSeconds(secondsToLatestMidpoint); | |
ZonedDateTime earliestMidpointInLa = earliestIndianaMidpoint.withZoneSameInstant(LA); | |
ZonedDateTime latestMidpointInLa = latestIndianaMidpoint.withZoneSameInstant(LA); | |
System.out.println("Earliest midpoint in LA: " + earliestMidpointInLa); | |
System.out.println("Latest midpoint in LA: " + latestMidpointInLa); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment