Add a Java 8 ISO 8601 time duration expression to java.util.Date
Add a Java 8 ISO 8601 time duration expression to java.util.Date I have an expression like "PT20.345S" , "P2DT3H4M" etc as described here https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence- "PT20.345S" "P2DT3H4M" How can I parse this, add it to the current time and get a java.util.Date object? java.util.Date Neither works: Date d1 = Date.from(LocalDateTime.now().plus(Duration.parse(_expression))); Date d2 = Date.from(Duration.parse(_expression).addTo(LocalDateTime.now())); FYI: (A) Try to avoid the java.util.Date class. Supplanted entirely by the java.time.Instant class years ago. (B) Never use LocalDateTime when you mean an actual moment, a specific point on the timeline. Use Instant , ZonedDateTime , or OffsetDateTime . – Basil Bourque Jun 30 at 23:50 ...