public final class NumberFormatUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static double |
getDouble(String str)
Parse string object to double type.
|
static double |
getDouble(String str,
boolean required)
Parse string object to double type.
|
static double |
getDouble(String str,
boolean required,
double defaultValue)
Parse string object to double type.
|
static double |
getDouble(String str,
double defaultValue)
Parse string object to double type.
|
static float |
getFloat(String str)
Parse string object to float type.
|
static float |
getFloat(String str,
boolean required)
Parse string object to float type.
|
static float |
getFloat(String str,
boolean required,
float defaultValue)
Parse string object to float type.
|
static float |
getFloat(String str,
float defaultValue)
Parse string object to float type.
|
static int |
getInt(String str)
Parse string object to int type.
|
static int |
getInt(String str,
boolean required)
Parse string object to int type.
|
static int |
getInt(String str,
boolean required,
int defaultValue)
Parse string object to int type.
|
static int |
getInt(String str,
int defaultValue)
Parse string object to int type.
|
static long |
getLong(String str)
Parse string object to long type.
|
static long |
getLong(String str,
boolean required)
Parse string object to long type.
|
static long |
getLong(String str,
boolean required,
long defaultValue)
Parse string object to long type.
|
static long |
getLong(String str,
long defaultValue)
Parse string object to long type.
|
public static int getInt(String str, int defaultValue)
str - string needed to be parseddefaultValue - default valuepublic static int getInt(String str)
str - string needed to be parsedpublic static int getInt(String str, boolean required)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replace; else use 0 as default
value.Exception - if invalid format with required set 'true'public static int getInt(String str, boolean required, int defaultValue)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replace; else use default value.defaultValue - default valueIllegalArgumentException - if invalid format with required set 'true'public static long getLong(String str, long defaultValue)
str - string needed to be parseddefaultValue - default valuepublic static long getLong(String str)
str - string needed to be parsedpublic static long getLong(String str, boolean required)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replaceIllegalArgumentException - if invalid format with required set 'true'public static long getLong(String str, boolean required, long defaultValue)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replace; else use default value.defaultValue - default valueException - if invalid format with required set 'true'public static double getDouble(String str, double defaultValue)
str - string needed to be parseddefaultValue - default valuepublic static double getDouble(String str)
str - string needed to be parsedpublic static double getDouble(String str, boolean required)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replaceException - if invalid format with required set 'true'public static double getDouble(String str, boolean required, double defaultValue)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replace; else use default value.defaultValue - default valueIllegalArgumentException - if invalid format with required set 'true'public static float getFloat(String str, float defaultValue)
str - string needed to be parseddefaultValue - default valuepublic static float getFloat(String str)
str - string needed to be parsedpublic static float getFloat(String str, boolean required)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replaceException - if invalid format with required set 'true'public static float getFloat(String str, boolean required, float defaultValue)
str - string needed to be parsedrequired - if required, should be parsed successfully without default value to replace; else use default value.defaultValue - default valueIllegalArgumentException - if invalid format with required set 'true'Copyright © 2018. All Rights Reserved.