Last active
November 6, 2022 10:30
-
-
Save joshlong/ea56774752ce0eb3a47ba457d9d2f065 to your computer and use it in GitHub Desktop.
calculates when the version of Java converges with its age. Assumes Java Beta came out January 1995.
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
// run with | |
// java DatesApplication.java | |
import java.time.LocalDate; | |
import java.time.temporal.ChronoUnit; | |
import java.util.Map; | |
public class DatesApplication { | |
public static void main(String[] args) { | |
var version = 19; | |
var birth = LocalDate.parse("1995-01-01"); | |
var now = LocalDate.parse("2022-09-20"); | |
var yearsSince = -1L; | |
while (version != yearsSince) { | |
now = now.plusMonths(6); | |
yearsSince = birth.until(now, ChronoUnit.MONTHS) / 12; | |
version += 1; | |
var s = Map.of( | |
"version", version,// | |
"years since 1.0", yearsSince,// | |
"now", now// | |
); | |
System.out.println(s); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment