public class NumberUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
arrayStore(int number,
byte[] array,
int startIndex) |
static void |
arrayStore(long number,
byte[] array,
int startIndex) |
static Double |
createDoubleQuietly(String s)
see
NumberUtils.createDouble(String) . |
static NumberUtils |
getInstance() |
static boolean |
isPositiveInteger(String input) |
static <T extends Comparable<? super T>> |
max(Collection<T> collection) |
static int |
max(int a,
int b) |
static int |
min(int a,
int b) |
static String |
padWithZeroes(Number value,
int numberOfZeroes) |
static long |
randomNonNegativeLong() |
static double |
round(double val,
int places) |
static float |
round(float val,
int places) |
static double |
stringToDouble(String s)
Deprecated.
since 4.2 consider using
createDoubleQuietly(String) |
static int |
stringToInt(String s) |
static long |
stringToLong(String s) |
static Integer |
toInteger(Number number) |
static double |
unlocalizedStringToDouble(String s)
Convert string to double value.
|
static long |
valueOf(Long l,
long defaultValue)
Null-safe unboxing of Long
|
public static NumberUtils getInstance()
public static long randomNonNegativeLong()
public static int min(int a, int b)
public static int max(int a, int b)
public static double round(double val, int places)
public static float round(float val, int places)
@Deprecated public static double stringToDouble(String s)
createDoubleQuietly(String)
@Nullable public static Double createDoubleQuietly(@Nullable String s)
NumberUtils.createDouble(String)
. Returns null instead of throwing
an exception.public static double unlocalizedStringToDouble(@Nullable String s)
Double.toString(double)
).
If the input cannot be parsed method would log this and return 0.
This method is intended to be used from FreeMarker code.s
- input string containing representation of a double value.public static long stringToLong(String s)
public static int stringToInt(String s)
public static <T extends Comparable<? super T>> T max(@NotNull Collection<T> collection)
public static boolean isPositiveInteger(@Nullable String input)
public static void arrayStore(int number, @NotNull byte[] array, int startIndex)
public static void arrayStore(long number, @NotNull byte[] array, int startIndex)
public static long valueOf(Long l, long defaultValue)
l
- value to unboxdefaultValue
- default value to return if l is nullCopyright © 2020 Atlassian Software Systems Pty Ltd. All rights reserved.