public class NumberHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
NumberHelper.ParseMode |
| Constructor and Description |
|---|
NumberHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
is(BigDecimal num1,
Comparator cmp,
BigDecimal num2)
Evaluates
num1 to num2 according to the operand cmp. |
static boolean |
is(Double num1,
Comparator cmp,
Double num2)
see ref
|
static boolean |
is(Long num1,
Comparator cmp,
Long num2)
see ref
|
static double |
parseDouble(String str,
NumberHelper.ParseMode parseMode)
Parses the given
str as double. |
static int |
parseInt(String str,
NumberHelper.ParseMode parseMode)
Parses the given
str as int. |
static long |
parseLong(String str,
NumberHelper.ParseMode parseMode)
Parses the given
str as long. |
public static boolean is(BigDecimal num1, Comparator cmp, BigDecimal num2)
num1 to num2 according to the operand cmp. is(5, Comparator.LTE, 5) = trueis(4, Comparator.LTE, 5) = trueis(5, Comparator.LTE, 4) = falseis(null, Comparator.LTE, 5) = falseis(null, Comparator.EQ, null) = trueis(null, Comparator.LTE, null) = falsenum1 - first numbercmp - Comparatornum2 - second numbernum1 satisfies the operand cmp when evaluated
to num2 num1 and num2 are null and Comparator.EQ is not usednum1 and num2 are null and Comparator.NEQ is usednum1 and num2 are not null and Comparator.NEQ is usednum1 or num2 is nullnum1 does not satisfy the operand cmp when evaluated to
num2public static boolean is(Double num1, Comparator cmp, Double num2)
num1 - first numbercmp - of type Comparatornum2 - second numberis(BigDecimal, Comparator, BigDecimal)public static boolean is(Long num1, Comparator cmp, Long num2)
num1 - first numbercmp - of type Comparatornum2 - second numberis(BigDecimal, Comparator, BigDecimal)public static double parseDouble(String str, NumberHelper.ParseMode parseMode)
str as double.str - to be parsed to doubleparseMode - to specify whether to suppress parsing exceptions or notNumberHelper.ParseMode.SUPPRESS_EXCEPTION, returns 0dNumberFormatException - if parseMode is NumberHelper.ParseMode.STRICTpublic static int parseInt(String str, NumberHelper.ParseMode parseMode)
str as int.str - to be parsed to intparseMode - to specify whether to suppress parsing exceptions or notNumberHelper.ParseMode.SUPPRESS_EXCEPTION,
returns 0NumberFormatException - if parseMode is NumberHelper.ParseMode.STRICTpublic static long parseLong(String str, NumberHelper.ParseMode parseMode)
str as long.str - to be parsed to longparseMode - to specify whether to suppress parsing exceptions or notNumberHelper.ParseMode.SUPPRESS_EXCEPTION,
returns 0LNumberFormatException - if parseMode is NumberHelper.ParseMode.STRICTCopyright © 2018. All rights reserved.