What is the Maximum value for Java Duration
It looks like Duration
is stored in seconds (up to Long.MAX_VALUE
) and nanoseconds (up to 999,999,999
). Then the biggest duration possible is:
Duration d = Duration.ofSeconds(Long.MAX_VALUE, 999_999_999);
When I print it (System.out.print(d)
) I get the following:
PT2562047788015215H30M7.999999999S
which means: 2562047788015215 hours, 30 minutes, and 7.999999999 seconds.
Simple:
Duration maxDur = ChronoUnit.FOREVER.getDuration();