{"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/5b2dbdbb8be64415eb6552f81ff7c449c8d251e6/build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/MavenBuildOutputTimestamp.java#L80-L112","documentation":"Thrown by MavenBuildOutputTimestamp.toInstant as an IllegalArgumentException catching a DateTimeParseException when the outputTimestamp is non-numeric (so it is treated as an ISO-8601 OffsetDateTime) but cannot be parsed. The parser expects ISO_OFFSET_DATE_TIME (e.g. 2024-01-01T00:00:00Z); any other format, a typo, or a stray token triggers this. The %s interpolates the offending input verbatim.","triggerScenarios":"Setting outputTimestamp to '2024-01-01' (date only, no time/offset); '2024/01/01 12:00:00' (wrong separators); a Git ISO-short format; a value like 'now' or '${maven.build.timestamp}'; a localized date string; an integer-like value that is not purely digits and not ISO.","commonSituations":"Using ${maven.build.timestamp} which is formatted by Maven's timestamp format (not ISO-8601 by default); passing a date from another tool with a different format; copy-pasting a date in a locale-specific format; using an ISO-local date without the time component.","solutions":["Use a strict ISO-8601 offset date-time: yyyy-MM-dd'T'HH:mm:ssXXX (e.g. 2024-01-01T00:00:00Z).","If you have epoch seconds, pass them as a plain integer string (digits only).","Avoid ${maven.build.timestamp} unless you have reformatted it to ISO-8601.","Set <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssXXX</maven.build.timestamp.format> if you must interpolate."],"exampleFix":"// before\n<project.build.outputTimestamp>2024-01-01</project.build.outputTimestamp>\n// after — full ISO-8601 offset date-time\n<project.build.outputTimestamp>2024-01-01T00:00:00Z</project.build.outputTimestamp>","handlingStrategy":"validation","validationCode":"// Reject non-ISO, non-numeric timestamps early\nimport java.time.OffsetDateTime, java.time.format.DateTimeParseException;\n\nvoid checkFormat(String ts) {\n    if (ts == null || ts.isBlank()) return;\n    if (ts.chars().allMatch(Character::isDigit)) return; // numeric epoch seconds\n    try { OffsetDateTime.parse(ts); }\n    catch (DateTimeParseException e) {\n        throw new IllegalArgumentException(\"outputTimestamp must be ISO-8601 or integer seconds: \" + ts);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use ISO-8601 offset date-time (yyyy-MM-dd'T'HH:mm:ssXXX) or pure integer epoch seconds.","Avoid interpolating ${maven.build.timestamp} unless reformatted to ISO-8601.","Document the accepted formats in the project to prevent contributors from using locale dates."],"tags":["maven","spring-boot","outputtimestamp","parsing","configuration"],"analyzedSha":"5b2dbdbb8be64415eb6552f81ff7c449c8d251e6","analyzedAt":"2026-08-04T18:53:14.967Z","schemaVersion":2}