diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java index 6bff863e178..60c01d18320 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java @@ -25,7 +25,9 @@ package jdk.javadoc.internal.doclets.formats.html; +import java.time.Instant; import java.time.ZonedDateTime; +import java.time.ZoneId; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; @@ -264,8 +266,12 @@ public class HtmlConfiguration extends BaseConfiguration { return false; } + ZonedDateTime now = ZonedDateTime.now(); + if ( System.getenv("SOURCE_DATE_EPOCH") != null ) { + now = ZonedDateTime.ofInstant(Instant.ofEpochMilli(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"))), ZoneId.of("UTC")); + } ZonedDateTime zdt = options.date(); - buildDate = zdt != null ? zdt : ZonedDateTime.now(); + buildDate = zdt != null ? zdt : now; if (!getSpecifiedTypeElements().isEmpty()) { Map map = new HashMap<>();