angular/components · error · Error

NOT_IMPLEMENTED

Error message

NOT_IMPLEMENTED

What it means

DateAdapter is an abstract base; setTime is an optional time-related method that the base implementation deliberately throws NOT_IMPLEMENTED. Only adapters for date types that support time (e.g. MomentDateAdapter, LuxonDateAdapter, or a native adapter subclass that overrides it) implement it. The stock NativeDateAdapter may not implement it unless the version does.

Source

Thrown at src/material/core/datetime/date-adapter.ts:203

   * @returns Whether the date is valid.
   */
  abstract isValid(date: D): boolean;

  /**
   * Gets date instance that is not valid.
   * @returns An invalid date.
   */
  abstract invalid(): D;

  /**
   * Sets the time of one date to the time of another.
   * @param target Date whose time will be set.
   * @param hours New hours to set on the date object.
   * @param minutes New minutes to set on the date object.
   * @param seconds New seconds to set on the date object.
   */
  setTime(target: D, hours: number, minutes: number, seconds: number): D {
    throw new Error(NOT_IMPLEMENTED);
  }

  /**
   * Gets the hours component of the given date.
   * @param date The date to extract the hours from.
   */
  getHours(date: D): number {
    throw new Error(NOT_IMPLEMENTED);
  }

  /**
   * Gets the minutes component of the given date.
   * @param date The date to extract the minutes from.
   */
  getMinutes(date: D): number {
    throw new Error(NOT_IMPLEMENTED);
  }

View on GitHub (pinned to 0411926e7d)

Solutions

  1. Use a date adapter that implements time support (e.g. MatMomentDateModule / MatLuxonDateModule) or upgrade to a version whose native adapter implements setTime
  2. Override setTime in your custom DateAdapter subclass, returning a copy of target with the given time
  3. Avoid calling time-based APIs if your date type cannot represent time

Example fix

// before
class MyAdapter extends DateAdapter<MyDate> { /* setTime not overridden */ }
adapter.setTime(d, 10, 30, 0); // throws
// after
class MyAdapter extends DateAdapter<MyDate> {
  setTime(target: MyDate, hours: number, minutes: number, seconds: number): MyDate {
    return {...target, hours, minutes, seconds};
  }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (adapter.setTime === DateAdapter.prototype.setTime) {
  throw new Error('This adapter does not support setTime');
}

Type guard

function supportsTime<D>(a: DateAdapter<D>): a is DateAdapter<D> & Required<Pick<DateAdapter<D>, 'setTime'|'getHours'|'getMinutes'|'getSeconds'>> {
  return a.setTime !== DateAdapter.prototype.setTime;
}

Try / catch

try {
  adapter.setTime(date, 10, 30, 0);
} catch (e) {
  if ((e as Error).message === 'NOT_IMPLEMENTED') {
    // fall back to constructing the date manually or use a time-capable adapter
  } else { throw e; }
}

Prevention

When it happens

Trigger: Calling adapter.setTime(date, h, m, s) on a DateAdapter instance whose concrete class has not overridden setTime.

Common situations: Using a custom date adapter that only implements the required abstract methods but not the optional time methods; using a date implementation (e.g. year/month-only dates) that cannot represent time; calling time features (timepicker) with an adapter lacking time support.

Related errors


AI-assisted analysis of angular/components@0411926e7d (2026-08-31). Data as JSON: /api/errors/8d1d1cbc0fd275a0. Report an issue: GitHub.