'Angular Material Datepicker internationalization example doesn't work

This example is in Angular Material documentation for dynamically changing locale for date picker component. But it doesn't work. What's weird is that the code snippet on documentation page works but the stackblitz doesn't.



Solution 1:[1]

If you want to change the language of your component you need to declare in your Constructor the DateAdapter, and you set the language like this:

constructor(private dateAdapter: DateAdapter<Date>) {
    this.dateAdapter.setLocale('it');
}

In my example i set the language in Italian.

Solution 2:[2]

It is possible to change locale dynamically for Angular material date picker.

working example - https://codesandbox.io/s/material-date-locale-jyylz

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hino-D-Bit
Solution 2 Pinaki