stanfordnlp/CoreNLP · error · UnsupportedOperationException

is not a fully specified date

Error message

%s is not a fully specified date

What it means

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.

Solutions

  1. Check that the Timex has a val and that it matches \\d{8} at the start before calling getDate()
  2. Use getRange(documentTime) instead, which handles durations and partial dates
  3. Parse the raw val string yourself for partial dates and fill unknown fields from the document time
  4. Wrap in try-catch for UnsupportedOperationException and skip unresolved TIMEX3 values

Example fix

// before
Calendar c = timex.getDate();
// after
if (timex.val() != null && timex.val().length() >= 8 && timex.val().substring(0,8).matches("\\d{8}")) {
  Calendar c = timex.getDate();
} else {
  Pair<Calendar,Calendar> range = timex.getRange(documentTime);
}
Defensive patterns

Strategy: validation

Validate before calling

boolean fullySpecified = t != null && t.val() != null && t.val().length() >= 8 && t.val().substring(0,8).matches("\\d{8}");

Type guard

boolean isFullDate(Timex t) { return t != null && t.val() != null && t.val().matches("\\d{8}.*"); }

Try / catch

try { Calendar c = timex.getDate(); } catch (UnsupportedOperationException e) { /* fall back to getRange(documentTime) */ }

Prevention

When it happens

Trigger: 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'.

Common situations: Parsing TimeBank/TimeML documents where TIMEX3 tags include durations, seasons, or unresolved dates, then blindly calling getDate() on every Timex extracted from the text.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/7f703598f705cc91. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/time/Timex.java:367

   * Gets the Calendar matching the year, month and day of this Timex.
   *
   * @return The matching Calendar.
   */
  public Calendar getDate() {
    if (val != null) {
      if (Pattern.matches("\\d\\d\\d\\d-\\d\\d-\\d\\d", this.val)) {
        int year = Integer.parseInt(this.val.substring(0, 4));
        int month = Integer.parseInt(this.val.substring(5, 7));
        int day = Integer.parseInt(this.val.substring(8, 10));
        return makeCalendar(year, month, day);
      } else if (Pattern.matches("\\d\\d\\d\\d\\d\\d\\d\\d", this.val)) {
        int year = Integer.parseInt(this.val.substring(0, 4));
        int month = Integer.parseInt(this.val.substring(4, 6));
        int day = Integer.parseInt(this.val.substring(6, 8));
        return makeCalendar(year, month, day);
      }
    }
    throw new UnsupportedOperationException(String.format("%s is not a fully specified date", this));
  }

  /**
   * Gets two Calendars, marking the beginning and ending of this Timex's range.
   *
   * @return The begin point and end point Calendars.
   */
  public Pair<Calendar, Calendar> getRange() {
    return this.getRange(null);
  }

  /**
   * Gets two Calendars, marking the beginning and ending of this Timex's range.
   *
   * @param documentTime
   *          The time the document containing this Timex was written. (Not
   *          necessary for resolving all Timex expressions. This may be
   *          {@code null}, but then relative time expressions cannot be

View on GitHub (pinned to 1b7edd19c4)