{"record":{"id":"1b99d9c820515cf6","repo":"GoogleContainerTools/jib","slug":"fieldname-must-be-a-number-of-milliseconds-sinc","errorCode":null,"errorMessage":"${fieldName} must be a number of milliseconds since epoch or an ISO 8601 formatted date","messagePattern":"(.+?) must be a number of milliseconds since epoch or an ISO 8601 formatted date","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Instants.java","lineNumber":52,"sourceCode":"   * @param fieldName name of field being parsed (for error messaging)\n   * @return Instant value of parsed time\n   */\n  public static Instant fromMillisOrIso8601(String time, String fieldName) {\n    try {\n      return Instant.ofEpochMilli(Long.parseLong(time));\n    } catch (NumberFormatException nfe) {\n      // TODO: copied from PluginConfigurationProcessor, find a way to share better\n      try {\n        DateTimeFormatter formatter =\n            new DateTimeFormatterBuilder()\n                .append(DateTimeFormatter.ISO_DATE_TIME)\n                .optionalStart()\n                .appendOffset(\"+HHmm\", \"+0000\")\n                .optionalEnd()\n                .toFormatter();\n        return formatter.parse(time, Instant::from);\n      } catch (DateTimeParseException dtpe) {\n        throw new IllegalArgumentException(\n            fieldName\n                + \" must be a number of milliseconds since epoch or an ISO 8601 formatted date\");\n      }\n    }\n  }\n}\n","sourceCodeStart":34,"sourceCodeEnd":59,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-cli/src/main/java/com/google/cloud/tools/jib/cli/Instants.java#L34-L59","documentation":"Jib CLI's Instants.fromMillisOrIso8601 accepts either epoch milliseconds or an ISO 8601 date string for fields like creation/modification times. If DateTimeFormatter.parse fails with DateTimeParseException after the numeric (millis) branch also failed, it throws IllegalArgumentException with this message naming the field.","triggerScenarios":"Passing a value to a time field (e.g. in a build file or CLI option) that is neither a number of milliseconds since epoch nor an ISO 8601 formatted date, e.g. '2024-01-01' without time context is fine but 'yesterday' or '01/02/2024' is not.","commonSituations":"Using human-friendly date strings or locale formats (MM/DD/YYYY), copying timestamps with stray whitespace or trailing 'Z' mismatches, config templating errors.","solutions":["Use a valid ISO 8601 string, e.g. 2024-01-15T10:30:00Z.","Use epoch milliseconds, e.g. 1705314600000.","Trim whitespace/quotes from the value in your config or script before passing it.","Check the error message for the exact fieldName and fix that field's value."],"exampleFix":"// before\ncreationTime = \"01/15/2024\"\n// after\ncreationTime = \"2024-01-15T00:00:00Z\"","handlingStrategy":"validation","validationCode":"boolean validInstant(String v) {\n  if (v == null) return false;\n  try { Long.parseLong(v.trim()); return true; }\n  catch (NumberFormatException ignored) {}\n  try { java.time.Instant.parse(v.trim()); return true; }\n  catch (java.time.format.DateTimeParseException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  jibBuild(config);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"must be a number of milliseconds since epoch or an ISO 8601\")) {\n    log.error(\"Fix time field value in config: {}\", e.getMessage());\n  } else throw e;\n}","preventionTips":["Store timestamps as epoch millis or strict ISO 8601 (with Z)","Trim and normalize time strings from templates/env","Validate config values with a schema before invoking Jib"],"tags":["cli","date-parsing","validation"],"backgroundTag":"invalid-date-format","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}