skip to content

German users of an Angular Material datepicker on provideNativeDateAdapter see 12.10.2026 in the input, but typing dates that way fails or lands on the wrong month; why, and what fixes it?

level: seniorimportance: should knowfreq 37%

answer

  1. display and parsing take different paths
  2. Intl formats, nothing parses
  3. the parse format argument is ignored
  4. implementation-defined string parsing
  5. an adapter with a real parse format

basics

~20 s

NativeDateAdapter formats through Intl.DateTimeFormat in the German locale but parses typed text with Date.parse, ignoring both locale and parse format, so day-first text is rejected or read month-first. Switch to the date-fns, Luxon or Moment adapter with a German parse format.

solid answer

~50 s

`NativeDateAdapter` is asymmetric. Its `format` builds an `Intl.DateTimeFormat` with the adapter locale, which inherits `'de'` from `LOCALE_ID` through `MAT_DATE_LOCALE`, so the input shows `12.10.2026`. Its `parse` ignores both the `parseFormat` argument and the locale and returns `new Date(Date.parse(text))`, and `Date.parse` handles non-ISO strings in an implementation-defined way. Depending on the browser, `24.10.2026` becomes an Invalid Date, which the input reports as `matDatepickerParse`, while `12.10.2026` may be read month-first as 10 December with no error at all; on blur the input reformats it and the text flips to `10.12.2026`. That is why the Material guide lists only en-US as supported for the native adapter. The fix is an adapter that honours `parse.dateInput`: `provideDateFnsAdapter()` with the `de` locale object keeps the `Date` type, and Luxon or Moment work too. Subclassing `NativeDateAdapter` to override `parse` is the last resort.

code

ts · 22 lines
ts
import {ApplicationConfig} from '@angular/core';
import {MAT_DATE_LOCALE} from '@angular/material/core';
import {provideDateFnsAdapter} from '@angular/material-date-fns-adapter';
import {de} from 'date-fns/locale';

export const appConfig: ApplicationConfig = {
  providers: [
    provideDateFnsAdapter({
      parse: {dateInput: ['dd.MM.yyyy', 'd.M.yyyy'], timeInput: 'HH:mm'},
      display: {
        dateInput: 'dd.MM.yyyy',
        timeInput: 'HH:mm',
        monthYearLabel: 'LLL yyyy',
        dateA11yLabel: 'PPP',
        monthYearA11yLabel: 'LLLL yyyy',
        timeOptionLabel: 'HH:mm',
      },
    }),
    // date-fns needs the Locale object, not the string 'de'
    {provide: MAT_DATE_LOCALE, useValue: de},
  ],
};

go deeper

for a junior

Recall that the native adapter only works reliably for en-US style typing, and that a matDatepickerParse error means the typed text could not be read.

for a middle

Explain the asymmetry: format uses Intl with the locale, parse uses Date.parse and ignores parse.dateInput, while deserialize handles backend ISO strings separately.

for a senior

Diagnose the silent month-first misread from the blur reformat, choose a replacement adapter with explicit parse formats, and add typed-input tests in the target locale.

for a principal

Treat date input as a localisation contract: pick one adapter for every locale the product serves rather than letting display and parsing quietly use different rules.

## The symptom A car-rental site is built with `LOCALE_ID` set to `'de'` and uses `provideNativeDateAdapter()`. A date picked from the calendar appears as `12.10.2026`, exactly as a German user expects. But when users type a return date the same way, one of two things happens: the field turns invalid, or it accepts the text and, on blur, rewrites it as a different date. Support tickets say "the return date jumps to December". ## Display and parsing take different paths The native adapter, `NativeDateAdapter` from `@angular/material/core`, works with JavaScript `Date` objects and has no parsing library behind it. | Adapter method | What the native adapter does | Uses the locale? | Uses `MAT_DATE_FORMATS`? | |---|---|---|---| | `format` | `new Intl.DateTimeFormat(locale, display.dateInput)` | yes | yes, as Intl options | | `parse` | `new Date(Date.parse(text))` | no | no, the argument is ignored | | `deserialize` | ISO 8601 regex, then `new Date(value)` | no | no | | `parseTime` | a regex for `1:45 PM`, `22:45` or `22.45` | no | no | Formatting is fully localised, so the display looks right. Parsing is not localised at all. The source comment says it plainly: native `Date` gives no way to set the parse format or locale, so both parameters are ignored. ## Why Date.parse is the wrong tool - The JavaScript specification defines only an ISO-style format for `Date.parse`; any other string is parsed in an **implementation-defined** way. - A dotted, day-first string such as `24.10.2026` has no portable meaning. Some engines reject it, others guess. - When an engine guesses, it tends toward month-first order, so `12.10.2026` can become 10 December 2026 while `24.10.2026`, with no month 24, fails. - No locale ever reaches the parser, so setting `LOCALE_ID` or `MAT_DATE_LOCALE` cannot change the outcome. ## What the user sees 1. Typed text the engine rejects gives an invalid `Date`; the datepicker input's validator reports **`matDatepickerParse`**, carrying the original text. 2. Typed text the engine misreads is a valid `Date` for the wrong day. No error appears. 3. On blur, the input reformats any valid value with `display.dateInput`, so the misread value is shown back in German order, for example `10.12.2026`. That flip is the giveaway. 4. Values from the backend still work, because ISO 8601 strings such as `2026-10-12` go through `deserialize`, not `parse`. ## Fixing it - **Use an adapter that parses with a format.** `provideDateFnsAdapter()` keeps `Date` values, honours `parse.dateInput` (the default `'P'` is the locale's short date) and needs the `de` `Locale` object from `date-fns/locale` in `MAT_DATE_LOCALE`. `provideLuxonDateAdapter()` and `provideMomentDateAdapter()` also parse with the configured format and accept an array of formats tried in order. - **Say the format.** The Material guide recommends always communicating the expected format next to the field; with a form field that is usually a hint reading `TT.MM.JJJJ`. - **Last resort: subclass.** Extending `NativeDateAdapter` and overriding `parse` to split day, month and year yourself works, but you now own a date parser. - **Test typed input in the target locale.** A calendar-only test will never catch this, because the calendar path never parses text.

  • Why do dates bound from the backend display correctly when typed dates fail?
    Bound values go through the adapter's `deserialize`, which accepts ISO 8601 strings such as `2026-10-12` and `Date` objects. Typed text goes through `parse`, which for the native adapter is `Date.parse` with no format or locale. Unambiguous machine formats survive; human, locale-ordered text does not.
  • How would you prove the parse path is the culprit in a bug report?
    Reproduce by typing, not clicking, then check the control: a `matDatepickerParse` error means the text was rejected, while a valid value whose blur-reformatted text differs from what was typed means it was misread. Picking the same day in the calendar works, which isolates parsing from display.

  • Setting LOCALE_ID to 'de' makes the native adapter parse day-first.
  • Passing German Intl options as parse.dateInput fixes native parsing.
  • Date.parse reads dotted day-first dates the same way in every browser.
  • If the calendar shows German dates, typed German dates must parse too.
  • The only cure is to subclass NativeDateAdapter and write a parser.