public class TypeDistiller
extends java.lang.Object
IParsedValueException if the input string cannot be converted.| Modifier and Type | Method and Description |
|---|---|
static java.lang.Number |
convertNumberTo(java.lang.Number number,
java.lang.Class<?> targetType)
Converts the given number to the specified target type.
|
static boolean |
getBool(java.lang.String s)
Deprecated.
Use
parseBoolean(String) instead. |
static boolean |
getBool(java.lang.String s,
boolean defaultValue)
Deprecated.
Use
parseBoolean(String, Boolean) instead. |
static boolean |
getBool(java.lang.String s,
java.lang.Boolean defaultValue)
Deprecated.
Use
parseBoolean(String, Boolean) instead. |
static java.lang.Boolean |
getBoolObject(java.lang.String s)
Deprecated.
Use
parseBooleanObject(String) instead. |
static java.lang.Boolean |
getBoolObject(java.lang.String s,
java.lang.Boolean defaultValue)
Deprecated.
Use
parseBooleanObject(String, Boolean) instead. |
static java.lang.Boolean |
getBoolObject(java.lang.String s,
java.lang.Boolean defaultValue,
boolean useDefaultValue)
Deprecated.
Use
parseBooleanObject(String) or parseBooleanObject(String, Boolean) instead. |
static java.math.BigDecimal |
getDecimalObject(java.lang.String s)
Deprecated.
Use
parseBigDecimal(String) instead. |
static java.math.BigDecimal |
getDecimalObject(java.lang.String s,
java.math.BigDecimal defaultValue)
Deprecated.
Use
parseBigDecimal(String, BigDecimal) instead. |
static double |
getDouble(java.lang.String s)
Deprecated.
Use
parseDouble(String) instead. |
static double |
getDouble(java.lang.String s,
double defaultValue)
Deprecated.
Use
parseDouble(String, double) instead. |
static java.lang.Double |
getDoubleObject(java.lang.String s)
Deprecated.
Use
parseDoubleObject(String) instead. |
static java.lang.Double |
getDoubleObject(java.lang.String s,
java.lang.Double defaultValue)
Deprecated.
Use
parseDoubleObject(String, Double) instead. |
static float |
getFloat(java.lang.String s)
Deprecated.
Use
parseFloat(String) instead. |
static float |
getFloat(java.lang.String s,
float defaultValue)
Deprecated.
Use
parseFloat(String, float) instead. |
static java.lang.Float |
getFloatObject(java.lang.String s)
Deprecated.
Use
parseFloatObject(String) instead. |
static java.lang.Float |
getFloatObject(java.lang.String s,
java.lang.Float defaultValue)
Deprecated.
Use
parseFloatObject(String, Float) instead. |
static int |
getInt(java.lang.String s)
Deprecated.
Use
parseInt(String) instead. |
static int |
getInt(java.lang.String s,
int defaultValue)
Deprecated.
Use
parseInt(String, int) instead. |
static java.lang.Integer |
getIntObject(java.lang.String s)
Deprecated.
Use
parseInteger(String) instead. |
static java.lang.Integer |
getIntObject(java.lang.String s,
java.lang.Integer defaultValue)
Deprecated.
Use
parseInteger(String, Integer) instead. |
static long |
getLong(java.lang.String s)
Deprecated.
Use
parseLong(String) instead. |
static long |
getLong(java.lang.String s,
long defaultValue)
Deprecated.
Use
parseLong(String, long) instead. |
static java.lang.Long |
getLongObject(java.lang.String s)
Deprecated.
Use
parseLongObject(String) instead. |
static java.lang.Long |
getLongObject(java.lang.String s,
java.lang.Long defaultValue)
Deprecated.
Use
parseLongObject(String, Long) instead. |
static int |
getRoundingMode(java.lang.String s)
Deprecated.
Use
parseRoundingMode(String) instead. |
static java.util.List<java.lang.String> |
getValidBooleanStrings()
Returns a list of all valid boolean strings (case-insensitive).
|
static java.util.List<java.lang.String> |
getValidRoundingModeStrings()
Returns a list of all valid rounding mode strings (case-insensitive).
|
static java.math.BigDecimal |
parseBigDecimal(java.lang.String s)
Parses a
BigDecimal from the given string. |
static java.math.BigDecimal |
parseBigDecimal(java.lang.String s,
java.math.BigDecimal defaultValue)
Parses a
BigDecimal from the given string. |
static boolean |
parseBoolean(java.lang.String s)
Parses a boolean value from a string representation (case-insensitive).
|
static boolean |
parseBoolean(java.lang.String s,
java.lang.Boolean defaultValue)
Parses a boolean value from a string representation (case-insensitive), with a default value for null input.
|
static java.lang.Boolean |
parseBooleanObject(java.lang.String s)
Parses a boolean value from a string representation (case-insensitive), returning a Boolean object.
|
static java.lang.Boolean |
parseBooleanObject(java.lang.String s,
java.lang.Boolean defaultValue)
Parses a boolean value from a string representation (case-insensitive), with a default value for null input, returning a Boolean object.
|
static double |
parseDouble(java.lang.String s)
Parses a double from the given string.
|
static double |
parseDouble(java.lang.String s,
double defaultValue)
Parses a double from the given string.
|
static java.lang.Double |
parseDoubleObject(java.lang.String s)
Parses a double from the given string.
|
static java.lang.Double |
parseDoubleObject(java.lang.String s,
java.lang.Double defaultValue)
Parses a double from the given string.
|
static float |
parseFloat(java.lang.String s)
Parses a float from the given string.
|
static float |
parseFloat(java.lang.String s,
float defaultValue)
Parses a float from the given string.
|
static java.lang.Float |
parseFloatObject(java.lang.String s)
Parses a float from the given string.
|
static java.lang.Float |
parseFloatObject(java.lang.String s,
java.lang.Float defaultValue)
Parses a float from the given string.
|
static int |
parseInt(java.lang.String s)
Parses an integer from the given string, ignoring decimal places.
|
static int |
parseInt(java.lang.String s,
int defaultValue)
Parses an integer from the given string, ignoring decimal places.
|
static java.lang.Integer |
parseInteger(java.lang.String str)
Parses an integer from the given string, ignoring decimal places.
|
static java.lang.Integer |
parseInteger(java.lang.String s,
java.lang.Integer defaultValue)
Parses an integer from the given string, ignoring decimal places.
|
static long |
parseLong(java.lang.String s)
Parses a long from the given string, ignoring decimal places.
|
static long |
parseLong(java.lang.String s,
long defaultValue)
Parses a long from the given string, ignoring decimal places.
|
static java.lang.Long |
parseLongObject(java.lang.String s)
Parses a long from the given string, ignoring decimal places.
|
static java.lang.Long |
parseLongObject(java.lang.String s,
java.lang.Long defaultValue)
Parses a long from the given string, ignoring decimal places.
|
static java.time.Period |
parsePeriod(java.lang.String s)
Parses a
Period from a string representation. |
static int |
parseRoundingMode(java.lang.String s)
Parses a rounding mode from a string representation.
|
public static java.util.List<java.lang.String> getValidBooleanStrings()
public static java.util.List<java.lang.String> getValidRoundingModeStrings()
public static int parseInt(java.lang.String s)
s - the string to parseIParsedValueException - if the string is null, empty, or not a valid integerpublic static int parseInt(java.lang.String s,
int defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyIParsedValueException - if the string is not a valid integerpublic static java.lang.Integer parseInteger(java.lang.String str)
str - the string to parseInteger objectIParsedValueException - if the string is null, empty, or not a valid integerpublic static java.lang.Integer parseInteger(java.lang.String s,
java.lang.Integer defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyInteger object, or the default value if the string is null or emptyIParsedValueException - if the string is not a valid integer@Deprecated public static int getInt(java.lang.String s)
parseInt(String) instead.@Deprecated
public static int getInt(java.lang.String s,
int defaultValue)
parseInt(String, int) instead.@Deprecated public static java.lang.Integer getIntObject(java.lang.String s)
parseInteger(String) instead.@Deprecated
public static java.lang.Integer getIntObject(java.lang.String s,
java.lang.Integer defaultValue)
parseInteger(String, Integer) instead.public static long parseLong(java.lang.String s)
s - the string to parseIParsedValueException - if the string is null, empty, or not a valid longpublic static long parseLong(java.lang.String s,
long defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyIParsedValueException - if the string is not a valid longpublic static java.lang.Long parseLongObject(java.lang.String s)
s - the string to parseLong objectIParsedValueException - if the string is null, empty, or not a valid longpublic static java.lang.Long parseLongObject(java.lang.String s,
java.lang.Long defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyLong object, or the default value if the string is null or emptyIParsedValueException - if the string is not a valid long@Deprecated public static long getLong(java.lang.String s)
parseLong(String) instead.@Deprecated
public static long getLong(java.lang.String s,
long defaultValue)
parseLong(String, long) instead.@Deprecated public static java.lang.Long getLongObject(java.lang.String s)
parseLongObject(String) instead.@Deprecated
public static java.lang.Long getLongObject(java.lang.String s,
java.lang.Long defaultValue)
parseLongObject(String, Long) instead.public static float parseFloat(java.lang.String s)
s - the string to parseIParsedValueException - if the string is null, empty, or not a valid floatpublic static float parseFloat(java.lang.String s,
float defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyIParsedValueException - if the string is not a valid floatpublic static java.lang.Float parseFloatObject(java.lang.String s)
s - the string to parseFloat objectIParsedValueException - if the string is null, empty, or not a valid floatpublic static java.lang.Float parseFloatObject(java.lang.String s,
java.lang.Float defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyFloat object, or the default value if the string is null or emptyIParsedValueException - if the string is not a valid float@Deprecated public static float getFloat(java.lang.String s)
parseFloat(String) instead.@Deprecated
public static float getFloat(java.lang.String s,
float defaultValue)
parseFloat(String, float) instead.@Deprecated public static java.lang.Float getFloatObject(java.lang.String s)
parseFloatObject(String) instead.@Deprecated
public static java.lang.Float getFloatObject(java.lang.String s,
java.lang.Float defaultValue)
parseFloatObject(String, Float) instead.public static java.math.BigDecimal parseBigDecimal(java.lang.String s)
BigDecimal from the given string.s - the string to parseBigDecimal valueIParsedValueException - if the string is null, empty, or not a valid BigDecimalpublic static java.math.BigDecimal parseBigDecimal(java.lang.String s,
java.math.BigDecimal defaultValue)
BigDecimal from the given string. Returns the default value if the string is null or empty.s - the string to parsedefaultValue - the default value to return if the string is null or emptyBigDecimal value, or the default value if the string is null or emptyIParsedValueException - if the string is not a valid BigDecimal@Deprecated public static java.math.BigDecimal getDecimalObject(java.lang.String s)
parseBigDecimal(String) instead.@Deprecated
public static java.math.BigDecimal getDecimalObject(java.lang.String s,
java.math.BigDecimal defaultValue)
parseBigDecimal(String, BigDecimal) instead.public static double parseDouble(java.lang.String s)
s - the string to parseIParsedValueException - if the string is null, empty, or not a valid doublepublic static double parseDouble(java.lang.String s,
double defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyIParsedValueException - if the string is not a valid doublepublic static java.lang.Double parseDoubleObject(java.lang.String s)
s - the string to parseDouble objectIParsedValueException - if the string is null, empty, or not a valid doublepublic static java.lang.Double parseDoubleObject(java.lang.String s,
java.lang.Double defaultValue)
s - the string to parsedefaultValue - the default value to return if the string is null or emptyDouble object, or the default value if the string is null or emptyIParsedValueException - if the string is not a valid double@Deprecated public static double getDouble(java.lang.String s)
parseDouble(String) instead.@Deprecated
public static double getDouble(java.lang.String s,
double defaultValue)
parseDouble(String, double) instead.@Deprecated public static java.lang.Double getDoubleObject(java.lang.String s)
parseDoubleObject(String) instead.@Deprecated
public static java.lang.Double getDoubleObject(java.lang.String s,
java.lang.Double defaultValue)
parseDoubleObject(String, Double) instead.public static boolean parseBoolean(java.lang.String s)
This method converts a string into its corresponding boolean value.
The following strings are considered true: "true", "yes", "1".
The following strings are considered false: "false", "no", "0".
This method uses BooleanToken to define the valid boolean string representations.
s - The string to parse.IParsedValueException - If the input string is not a valid boolean representation.BooleanTokenpublic static boolean parseBoolean(java.lang.String s,
java.lang.Boolean defaultValue)
This method converts a string into its corresponding boolean value.
The supported string representations are defined in BooleanToken.
Examples of valid input strings (case-insensitive):
s - The string to parse.defaultValue - The default value to return if the input string is null.IParsedValueException - If the input string is not a valid boolean representation.public static java.lang.Boolean parseBooleanObject(java.lang.String s)
This method is similar to parseBoolean(String), but it returns a Boolean object instead of a primitive boolean value.
This allows for explicitly representing a null value when the input string is null.
The following strings are considered true: "true", "yes", "1".
The following strings are considered false: "false", "no", "0".
This method uses BooleanToken to define the valid boolean string representations.
s - The string to parse.Boolean object, or null if the input string is null.IParsedValueException - If the input string is not a valid boolean representation.parseBoolean(String)public static java.lang.Boolean parseBooleanObject(java.lang.String s,
java.lang.Boolean defaultValue)
This method converts a string into its corresponding boolean value.
The following strings are considered true: "true", "yes", "1".
The following strings are considered false: "false", "no", "0".
This method uses BooleanToken to define the valid boolean string representations.
If the input string is null, the specified default value is returned.
s - The string to parse.sdefaultValue - The default value to return if the input string is null.Boolean object, or the default value if the input string is null.IParsedValueException - If the input string is not a valid boolean representation.@Deprecated public static boolean getBool(java.lang.String s)
parseBoolean(String) instead.@Deprecated
public static boolean getBool(java.lang.String s,
boolean defaultValue)
parseBoolean(String, Boolean) instead.@Deprecated
public static boolean getBool(java.lang.String s,
java.lang.Boolean defaultValue)
parseBoolean(String, Boolean) instead.@Deprecated public static java.lang.Boolean getBoolObject(java.lang.String s)
parseBooleanObject(String) instead.@Deprecated
public static java.lang.Boolean getBoolObject(java.lang.String s,
java.lang.Boolean defaultValue)
parseBooleanObject(String, Boolean) instead.@Deprecated
public static java.lang.Boolean getBoolObject(java.lang.String s,
java.lang.Boolean defaultValue,
boolean useDefaultValue)
parseBooleanObject(String) or parseBooleanObject(String, Boolean) instead.public static java.time.Period parsePeriod(java.lang.String s)
Period from a string representation.
This method converts a string in the format "10y", "5M", "2w", etc. into its corresponding
Period object. The supported units are defined in PeriodUnit.
Examples of valid input strings:
s - the string to parsePeriod objectIParsedValueException - if the input string is null, empty, or does not represent a valid periodpublic static int parseRoundingMode(java.lang.String s)
This method converts a string into its corresponding SimpleRoundingMode enum value
and extracts the associated rounding mode as an integer.
The input string is case-insensitive.
The supported rounding modes are defined in SimpleRoundingMode.
s - The string representation of the rounding mode.java.lang.IllegalArgumentException - if the input string is null, empty, or does not represent a valid rounding mode.@Deprecated public static int getRoundingMode(java.lang.String s)
parseRoundingMode(String) instead.public static java.lang.Number convertNumberTo(java.lang.Number number,
java.lang.Class<?> targetType)
Byte, Short, Integer, Long, Float, Double, and BigDecimal.number - the number to converttargetType - the target typejava.lang.IllegalArgumentException - if the conversion is not supportedCopyright © 2000-2025 OAshi S.à r.l. All Rights Reserved.