Skip to content

Instantly share code, notes, and snippets.

@joshlong
Last active November 6, 2022 10:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshlong/ea56774752ce0eb3a47ba457d9d2f065 to your computer and use it in GitHub Desktop.
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.
// 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