import moment from 'moment' //import 'moment/locale/pt-br'; const SQL_DATE_FORMAT = 'YYYY-MM-DD'; export class DateFormat { private i18nService; constructor(i18nService) { this.i18nService = i18nService; } formatDate(value: any, componentName?: string): string { //moment.locale( this.i18nService.getLanguageId() ); let format = componentName ? this.i18nService.lookup('dateFormat', componentName) : this.i18nService.lookup('dateFormat'); if (format) { return moment(value).format(format); } else { return moment(value).format(SQL_DATE_FORMAT); } } formatDateWithTokens(value: any, format: string): string { moment.locale( this.i18nService.getLanguageId() ); return moment(value).format(format); } }