public class ParsingUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ParsingUtils.ScaleUnit
ScaleUnit.
|
Modifier and Type | Field and Description |
---|---|
protected static java.util.Collection<java.lang.String> |
FALSES
strings meaning boolean's false.
|
static java.util.List<ParsingUtils.ScaleUnit> |
INTERVALS
Parsing Interval.
|
protected static java.util.Collection<java.lang.String> |
TRUES
strings meaning boolean's true.
|
Constructor and Description |
---|
ParsingUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
convertToBoolean(java.lang.String val)
Parse
val and convert to boolean type. |
static boolean |
convertToBoolean(java.lang.String str,
boolean defaultValueIsTrue)
Parse
str and convert to boolean . |
static long |
convertToCapacity(java.lang.String str,
long defaultValue)
Parse
str and convert capacity in bytes. |
static double |
convertToDouble(java.lang.String val)
Parse
val and convert to double type. |
static double |
convertToDouble(java.lang.String val,
double defaultValue)
Parse
val and convert to double type. |
static int |
convertToInt(java.lang.String val)
Parse
val and convert to int type. |
static int |
convertToInt(java.lang.String val,
int defaultValue)
Parse
val and convert to int type. |
static long |
convertToLong(java.lang.String val)
Parse
val and convert to long type. |
static long |
convertToLong(java.lang.String val,
int defaultValue)
Parse
val and convert to long type. |
static long |
convertToLong(java.lang.String val,
long defaultValue)
Parse
val and convert to long type. |
static long |
convertToTime(java.lang.String val)
Parse
val and convert time in microseconds. |
static long |
parse(java.lang.String val,
java.util.concurrent.TimeUnit unit)
Parse
val and convert time in unit . |
protected static final java.util.Collection<java.lang.String> TRUES
protected static final java.util.Collection<java.lang.String> FALSES
public static final java.util.List<ParsingUtils.ScaleUnit> INTERVALS
time units, which is based on milliseconds
public static boolean convertToBoolean(java.lang.String str, boolean defaultValueIsTrue)
str
and convert to boolean
.
Check str
means true
if defaultValue
is false
.
Check str
means false
if defaultValue
is true
.
public static boolean convertToBoolean(java.lang.String val)
val
and convert to boolean
type.val
- string to parseconvertToBoolean(String, boolean)
public static int convertToInt(java.lang.String val)
val
and convert to int
type.val
- string to parseconvertToInt(String, int)
public static int convertToInt(java.lang.String val, int defaultValue)
val
and convert to int
type.
Return defaultValue
if can't parse.
val
- string to parsedefaultValue
- default valueNumberUtils.parse(String, Class)
public static long convertToLong(java.lang.String val)
val
and convert to long
type.val
- string to parseconvertToLong(String)
public static long convertToLong(java.lang.String val, int defaultValue)
val
and convert to long
type.
Return defaultValue
if can't parse.
val
- string to parsedefaultValue
- default valueNumberUtils.parse(String, Class)
public static long convertToLong(java.lang.String val, long defaultValue)
val
and convert to long
type.
Return default value if can't parse
val
- string to parsedefaultValue
- default valueNumberUtils.parse(String, Class)
public static double convertToDouble(java.lang.String val)
val
and convert to double
type.val
- string to parseconvertToDouble(String, double)
public static double convertToDouble(java.lang.String val, double defaultValue)
val
and convert to double
type.
Return defaultValue
if can't parse.
val
- string to parsedefaultValue
- default valueNumberUtils.parse(String, Class)
public static long convertToCapacity(java.lang.String str, long defaultValue)
str
and convert capacity in bytes.
Return defaultValue
if can't parse
str
- string to parsedefaultValue
- default valuepublic static long convertToTime(java.lang.String val) throws java.text.ParseException
val
and convert time in microseconds.val
- string to parsejava.text.ParseException
- Fail to parsepublic static long parse(java.lang.String val, java.util.concurrent.TimeUnit unit) throws java.text.ParseException
val
and convert time in unit
.val
- string to parseunit
- time unit to convertunit
java.text.ParseException
- Fail to parseconvertToTime(String)