import { isNullOrUndefined } from '@syncfusion/ej2-base' ; import { Internationalization , setCulture , NumberFormatOptions , DateFormatOptions } from '@syncfusion/ej2-base' ; import { IValueFormatter } from '../base/interface' ; hidden export class ValueFormatter implements IValueFormatter { private intl : Internationalization = new Internationalization ( ) ; constructor ( cultureName ? ) { if ( ! isNullOrUndefined ( cultureName ) ) { this . intl . culture = cultureName ; } } public getFormatFunction ( format ) { if ( ( < DateFormatOptions > format ) . type ) { return this . intl . getDateFormat ( < DateFormatOptions > format ) ; } else { return this . intl . getNumberFormat ( < DateFormatOptions > format ) ; } } public getParserFunction ( format ) { if ( ( < DateFormatOptions > format ) . type ) { return this . intl . getDateParser ( < DateFormatOptions > format ) ; } else { return this . intl . getNumberParser ( < DateFormatOptions > format ) ; } } public fromView ( value , format , type ? ) { if ( ( type === 'date' || type === 'datetime' || type === 'number' ) && ( ! isNullOrUndefined ( format ) ) ) { return format ( value ) ; } else { return value ; } } public toView ( value , format ) { let result = value ; if ( ! isNullOrUndefined ( format ) && ! isNullOrUndefined ( value ) ) { result = format ( value ) ; } return result ; } public setCulture ( cultureName ) { if ( ! isNullOrUndefined ( cultureName ) ) { setCulture ( cultureName ) ; } } }