public final class NumberUtils extends Object
| Constructor and Description |
|---|
NumberUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isNumeric(String value,
Locale locale)
Test, if a string contains a parsable number.
|
static Number |
parseNumber(String value)
Convert a string value into a number.
|
static Number |
parseNumber(String value,
boolean integerOnly,
Locale... locales)
Convert a string value into a number.
|
static Number |
parseNumber(String value,
Locale... locales)
Convert a string value into a number.
|
static String |
printNumber(Number value,
int integerDigits,
int fractionDigits)
Write a number into a string value.
|
static String |
printNumber(Number value,
int integerDigits,
int fractionDigits,
Locale locale)
Write a number into a string value.
|
public static boolean isNumeric(String value, Locale locale)
value - the value to checklocale - the locale, against which the value is checked
(checks locale specific decimal and grouping separators)public static Number parseNumber(String value) throws NumberFormatException
value - the string value to convertNumberFormatException - if the string is not a valid numberpublic static Number parseNumber(String value, Locale... locales) throws NumberFormatException
value - the string value to convertlocales - locales, against which the value is parsedNumberFormatException - if the string is not a valid numberpublic static Number parseNumber(String value, boolean integerOnly, Locale... locales) throws NumberFormatException
value - the string value to convertintegerOnly - wether only the integer part of the value is parsedlocales - locales, against which the value is parsedNumberFormatException - if the string is not a valid numberpublic static String printNumber(Number value, int integerDigits, int fractionDigits)
value - the number to writeintegerDigits - maximal number of integer digitsfractionDigits - maximal number of fraction digitspublic static String printNumber(Number value, int integerDigits, int fractionDigits, Locale locale)
value - the number to writeintegerDigits - maximal number of integer digitsfractionDigits - maximal number of fraction digitslocale - locale for decimal separator (using Locale.ENGLISH if null)Copyright © 2017 OpenEstate. All rights reserved.