{"record":{"id":"7f703598f705cc91","repo":"stanfordnlp/CoreNLP","slug":"s-is-not-a-fully-specified-date","errorCode":null,"errorMessage":"%s is not a fully specified date","messagePattern":"(.+?) is not a fully specified date","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/Timex.java","lineNumber":367,"sourceCode":"   * Gets the Calendar matching the year, month and day of this Timex.\n   *\n   * @return The matching Calendar.\n   */\n  public Calendar getDate() {\n    if (val != null) {\n      if (Pattern.matches(\"\\\\d\\\\d\\\\d\\\\d-\\\\d\\\\d-\\\\d\\\\d\", this.val)) {\n        int year = Integer.parseInt(this.val.substring(0, 4));\n        int month = Integer.parseInt(this.val.substring(5, 7));\n        int day = Integer.parseInt(this.val.substring(8, 10));\n        return makeCalendar(year, month, day);\n      } else if (Pattern.matches(\"\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\\\\d\", this.val)) {\n        int year = Integer.parseInt(this.val.substring(0, 4));\n        int month = Integer.parseInt(this.val.substring(4, 6));\n        int day = Integer.parseInt(this.val.substring(6, 8));\n        return makeCalendar(year, month, day);\n      }\n    }\n    throw new UnsupportedOperationException(String.format(\"%s is not a fully specified date\", this));\n  }\n\n  /**\n   * Gets two Calendars, marking the beginning and ending of this Timex's range.\n   *\n   * @return The begin point and end point Calendars.\n   */\n  public Pair<Calendar, Calendar> getRange() {\n    return this.getRange(null);\n  }\n\n  /**\n   * Gets two Calendars, marking the beginning and ending of this Timex's range.\n   *\n   * @param documentTime\n   *          The time the document containing this Timex was written. (Not\n   *          necessary for resolving all Timex expressions. This may be\n   *          {@code null}, but then relative time expressions cannot be","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/Timex.java#L349-L385","documentation":"Timex.getDate() throws UnsupportedOperationException when the Timex has no 'val' string, or a val that does not start with 8 digits (a full YYYYMMDD date). The method can only materialize a java.util.Calendar from a fully specified date, so partial values (e.g. '199X0804', 'P1D', season codes) cannot be converted.","triggerScenarios":"Calling getDate() on a Timex whose val is null, or whose val is not 8 leading digits — e.g. durations like 'P3M', quarter/season tags like '2009-SU', or partially unknown dates like 'XXXX0715'.","commonSituations":"Parsing TimeBank/TimeML documents where TIMEX3 tags include durations, seasons, or unresolved dates, then blindly calling getDate() on every Timex extracted from the text.","solutions":["Check that the Timex has a val and that it matches \\\\d{8} at the start before calling getDate()","Use getRange(documentTime) instead, which handles durations and partial dates","Parse the raw val string yourself for partial dates and fill unknown fields from the document time","Wrap in try-catch for UnsupportedOperationException and skip unresolved TIMEX3 values"],"exampleFix":"// before\nCalendar c = timex.getDate();\n// after\nif (timex.val() != null && timex.val().length() >= 8 && timex.val().substring(0,8).matches(\"\\\\d{8}\")) {\n  Calendar c = timex.getDate();\n} else {\n  Pair<Calendar,Calendar> range = timex.getRange(documentTime);\n}","handlingStrategy":"validation","validationCode":"boolean fullySpecified = t != null && t.val() != null && t.val().length() >= 8 && t.val().substring(0,8).matches(\"\\\\d{8}\");","typeGuard":"boolean isFullDate(Timex t) { return t != null && t.val() != null && t.val().matches(\"\\\\d{8}.*\"); }","tryCatchPattern":"try { Calendar c = timex.getDate(); } catch (UnsupportedOperationException e) { /* fall back to getRange(documentTime) */ }","preventionTips":["Always pair getDate() with a document creation time and use getRange() for non-point values","Check VAL format before any Calendar conversion","Skip or log TIMEX3 entries with X placeholders or duration values"],"tags":["java","date-parsing","timex"],"backgroundTag":"invalid-date-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"}