{"record":{"id":"c7a770d1da99d778","repo":"spring-projects/spring-boot","slug":"can-t-parse-s-to-instant","errorCode":null,"errorMessage":"Can't parse '%s' to instant","messagePattern":"Can't parse '(.+?)' to instant","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MavenBuildOutputTimestamp.java","lineNumber":98,"sourceCode":"\t\tif (!StringUtils.hasLength(this.timestamp)) {\n\t\t\treturn null;\n\t\t}\n\t\tif (isNumeric(this.timestamp)) {\n\t\t\treturn Instant.ofEpochSecond(Long.parseLong(this.timestamp));\n\t\t}\n\t\tif (this.timestamp.length() < 2) {\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tInstant instant = OffsetDateTime.parse(this.timestamp).withOffsetSameInstant(ZoneOffset.UTC).toInstant();\n\t\t\tif (instant.isBefore(DATE_MIN) || instant.isAfter(DATE_MAX)) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\tString.format(\"'%s' is not within the valid range %s to %s\", instant, DATE_MIN, DATE_MAX));\n\t\t\t}\n\t\t\treturn instant;\n\t\t}\n\t\tcatch (DateTimeParseException pe) {\n\t\t\tthrow new IllegalArgumentException(String.format(\"Can't parse '%s' to instant\", this.timestamp));\n\t\t}\n\t}\n\n\tprivate static boolean isNumeric(String str) {\n\t\tfor (char c : str.toCharArray()) {\n\t\t\tif (!Character.isDigit(c)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}\n","sourceCodeStart":80,"sourceCodeEnd":112,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MavenBuildOutputTimestamp.java#L80-L112","documentation":"IllegalArgumentException thrown by MavenBuildOutputTimestamp when the non-numeric, non-empty, ≥2-char outputTimestamp cannot be parsed as an OffsetDateTime (DateTimeParseException). The plugin only accepts two formats: pure epoch seconds (numeric) or a valid ISO-8601 offset date-time; anything else lands here.","triggerScenarios":"Setting <project.build.outputTimestamp> to a non-numeric, non-ISO-8601 string (e.g., '2024/01/01', 'Jan 1 2024', or a date without time/offset that OffsetDateTime.parse rejects).","commonSituations":"Using a locale-specific date format; passing a LocalDate-only string; missing the offset/zone portion; copy-pasting a timestamp from a non-Java source.","solutions":["Use the ISO-8601 offset form: <outputTimestamp>2024-01-01T00:00:00Z</outputTimestamp>.","Or use epoch seconds: <outputTimestamp>1700000000</outputTimestamp> (numeric branch, no parse).","Omit the property to disable reproducible-timestamp injection.","Validate the value with `OffsetDateTime.parse(...)` in a quick test."],"exampleFix":"// before: <project.build.outputTimestamp>2024/01/01 12:00</project.build.outputTimestamp>\n// after:  <project.build.outputTimestamp>2024-01-01T12:00:00Z</project.build.outputTimestamp>","handlingStrategy":"validation","validationCode":"// Validate format before invoking:\nString ts = outputTimestamp;\nboolean ok = (ts == null || ts.isEmpty())\n    || (ts.chars().allMatch(Character::isDigit))\n    || canParseOffsetDateTime(ts);\n// where:\nboolean canParseOffsetDateTime(String s) { try { OffsetDateTime.parse(s); return true; } catch (DateTimeParseException e) { return false; } }","typeGuard":null,"tryCatchPattern":"try {\n    // invoke goal that calls toFileTime\n} catch (IllegalArgumentException ex) {\n    if (ex.getMessage().startsWith(\"Can't parse\") && ex.getMessage().endsWith(\"to instant\")) {\n        // convert to ISO-8601 offset or epoch seconds, then retry\n    }\n    throw ex;\n}","preventionTips":["Always use ISO-8601 with explicit offset (e.g. 2024-01-01T00:00:00Z).","Avoid locale-specific date formats in build properties.","Add a CI lint that parses the configured outputTimestamp."],"tags":["spring-boot","maven-plugin","reproducible-builds","timestamp","parsing"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}