{"record":{"id":"2e211805bd9a56e8","repo":"stanfordnlp/CoreNLP","slug":"invalid-date-time-zone-offset-str","errorCode":null,"errorMessage":"Invalid date time zone offset ${str}","messagePattern":"Invalid date time zone offset (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/TimeFormatter.java","lineNumber":499,"sourceCode":"      }\n      return sb;\n    }\n\n    private static int parseInteger(String str, int pos, int length) {\n      return Integer.parseInt(str.substring(pos, pos+length));\n    }\n\n    public int parseOffsetMillis(String str) {\n      int offset = 0;\n      if (zeroOffsetParseText != null && str.equalsIgnoreCase(zeroOffsetParseText)) {\n        return offset;\n      }\n      boolean negative = false;\n      if (str.startsWith(\"+\")) {\n      } else if (str.startsWith(\"-\")) {\n        negative = true;\n      } else {\n        throw new IllegalArgumentException(\"Invalid date time zone offset \" + str);\n      }\n      int pos = 1;\n      // Parse hours\n      offset += DateTimeConstants.MILLIS_PER_HOUR * parseInteger(str, pos, 2);\n      pos += 2;\n      if (pos < str.length()) {\n        // Parse minutes\n        if (!Character.isDigit(str.charAt(pos))) { pos++; }\n        offset += DateTimeConstants.MILLIS_PER_MINUTE * parseInteger(str, pos, 2);\n        pos += 2;\n        if (pos < str.length()) {\n          // Parse seconds\n          if (!Character.isDigit(str.charAt(pos))) { pos++; }\n          offset += DateTimeConstants.MILLIS_PER_SECOND * parseInteger(str, pos, 2);\n          pos += 2;\n          if (pos < str.length()) {\n            // Parse fraction of seconds\n            if (!Character.isDigit(str.charAt(pos))) { pos++; }","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/TimeFormatter.java#L481-L517","documentation":"A parse failure in TimeFormatter.parseOffsetMillis: the string is expected to be a UTC-offset expression starting with '+' or '-' (or matching the zero-offset text); anything else, such as a bare offset without a sign, is rejected as an invalid date-time zone offset.","triggerScenarios":"Calling the TimeFormatter offset-parse path (e.g. via time zone parsing in a formatter) with a string like \"08:00\", \"Z\", \"GMT+8\", or an empty string — missing the required sign prefix.","commonSituations":"Passing \"Z\" (UTC designator) where a signed numeric offset is expected; stripping the '+' sign when cleaning timestamps; Excel/spreadsheet data that drops leading '+'.","solutions":["Normalize \"Z\" to \"+00:00\" (or \"-00:00\") before handing the string to the parser.","Ensure the offset always carries an explicit sign: prepend \"+\" if absent and the string starts with a digit.","Pre-validate with a regex like ^[+-]\\d{2}(:?\\d{2})?$ before invoking."],"exampleFix":"// before\nString tz = \"Z\";\nformatter.parseOffset(tz); // throws\n\n// after\nString tz = \"Z\".equals(raw) ? \"+00:00\" : raw;\nformatter.parseOffset(tz);","handlingStrategy":"validation","validationCode":"static boolean hasSign(String s) { return s != null && (s.startsWith(\"+\") || s.startsWith(\"-\")); }","typeGuard":null,"tryCatchPattern":"try {\n  offset = parseOffset(str);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid date time zone offset\")) {\n    if (str != null && str.startsWith(\"Z\")) str = \"+00:00\";\n    else if (str != null && str.matches(\"\\\\d.*\")) str = \"+\" + str;\n    offset = parseOffset(str);\n  } else throw e;\n}","preventionTips":["Translate 'Z' to '+00:00' at data-ingestion time.","Never strip the sign from ISO offsets during cleaning.","Regex-validate offsets before parsing."],"tags":["timezone","offset-parsing","illegal-argument","iso8601"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}