我正在使用角度垫日期输入,在 MomentDateAdapter 解析日期我想将输入数字转换为特定的日期格式。例如
| Input |InpurtFormat|OutputFormat| Output |
|-------:|-----------:|-----------:|---------:|
|21102012| DDMMYYYY | DD/MM/YYYY |21/10/2012|
|12212020| MMDDYYYY | MM/DD/YYYY |12/21/2020|
|20201221| YYYYMMDD | YYYY/MM/DD |2020/12/21|
parse(value: any, parseFormat: string | string[]): Moment | null {
if (value && typeof value === 'string') {
const format = this._dateTimeService.getFormat();
return moment.utc(value, format, this.locale, true);
}
return value ? moment.utc(value).locale(this.locale) : null;
}