public class Digits extends Object
| Constructor and Description |
|---|
Digits() |
| Modifier and Type | Method and Description |
|---|---|
static String |
format(long value,
int digits)
Zero-pads the given value until it is at least the specified length in
digits.
|
static String |
formatFractions(double value,
int fractionDigits,
boolean round)
Returns the given value formatted with the given number of fractional
digits, showing final zeroes as well.
|
static int |
parseInt(String digits)
Parses the given string into an int, throwing an exception if the string
contains invalid characters.
|
static int |
parseInt(String digits,
int defaultValue)
Parses the given string into an int, returning the given default value if
the string contains invalid characters.
|
static long |
parseLong(String digits)
Parses the given string into a long, throwing an exception if the string
contains invalid characters.
|
static long |
parseLong(String digits,
long defaultValue)
Parses the given string into a long, returning the given default value if
the string contains invalid characters.
|
static double |
round(double number,
double unit)
Rounds the given number to the nearest multiple of
unit. |
public static String format(long value, int digits)
value - The value to paddigits - The number of digits for the padded valuepublic static String formatFractions(double value, int fractionDigits, boolean round)
value - The value to formatfractionDigits - The number of fractional digitsround - true to round the formatted value,
false to truncate itpublic static long parseLong(String digits) throws NumberFormatException
digits - The number string to parseNumberFormatException - if the number string contains invalid characterspublic static long parseLong(String digits, long defaultValue)
digits - The number string to parsedefaultValue - The value to return if the string can not be parsedpublic static int parseInt(String digits) throws NumberFormatException
digits - The number string to parseNumberFormatException - if the number string contains invalid characterspublic static int parseInt(String digits, int defaultValue)
digits - The number string to parsedefaultValue - The value to return if the string can not be parsedpublic static double round(double number,
double unit)
unit.number - The number to roundunit - The unit to round toCopyright © 2026. All rights reserved.