@eclipse-scout/core
Version:
Eclipse Scout runtime
69 lines • 2.5 kB
TypeScript
import { Locale, RoundingMode } from '../index';
/**
* Provides formatting of numbers using java format pattern.
*
* Compared to the java DecimalFormat the following pattern characters are not considered:
* - E
* - %
*/
export declare class DecimalFormat {
positivePrefix: string;
positiveSuffix: string;
negativePrefix: string;
negativeSuffix: string;
groupingChar: string;
lenientGroupingChars: string;
groupLength: number;
decimalSeparatorChar: string;
zeroBefore: number;
zeroAfter: number;
allAfter: number;
pattern: string;
multiplier: number;
roundingMode: RoundingMode;
constructor(locale: Locale, options?: string | DecimalFormatOptions);
/**
* Converts the numberString into a number and applies the multiplier.
* @param evaluateNumberFunction optional function for custom evaluation. The function gets a normalized string and has to return a Number
* @returns A number for the given numberString, if the string can be converted into a number. Throws an Error otherwise
*/
parse(numberString: string, evaluateNumberFunction?: (normalizedNumberString: string) => number): number;
format(number: number, applyMultiplier?: boolean): string;
/**
* Rounds a number according to the properties of the DecimalFormat.
*/
round(number: number, applyMultiplier?: boolean): number;
/**
* Convert to JS number format:
* - remove groupingChar and lenientGroupingChars
* - replace decimalSeparatorChar with '.'
* - remove positiveSuffix and negativeSuffix
* - replace positivePrefix with '+'
* - replace negativePrefix with '-'
*/
normalize(numberString: string): string;
/**
* Literal (not localized!) pattern symbols as defined in http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html
*/
static PATTERN_SYMBOLS: {
readonly digit: "#";
readonly zeroDigit: "0";
readonly decimalSeparator: ".";
readonly groupingSeparator: ",";
readonly minusSign: "-";
readonly patternSeparator: ";";
};
static ensure(locale: Locale, format: DecimalFormat | string | DecimalFormatOptions): DecimalFormat;
}
export interface DecimalFormatOptions {
pattern: string;
/**
* default is 1
*/
multiplier?: number;
/**
* default is {@link RoundingMode.HALF_UP}
*/
roundingMode?: RoundingMode;
}
//# sourceMappingURL=DecimalFormat.d.ts.map