public class NumberUtils extends Object
Provides extra functionality for Java Number classes.
| 构造器和说明 |
|---|
NumberUtils()
NumberUtils instances should NOT be constructed in standard programming. |
public NumberUtils()
NumberUtils instances should NOT be constructed in standard programming.
Instead, the class should be used as NumberUtils.toInt("6");.
This constructor is public to permit tools that require a JavaBean instance to operate.
public static int toInt(String str, int defaultValue)
Convert a String to an int, returning a
default value if the conversion fails.
If the string is null, the default value is returned.
NumberUtils.toInt(null, 1) = 1
NumberUtils.toInt("", 1) = 1
NumberUtils.toInt("1", 0) = 1
str - the string to convert, may be nulldefaultValue - the default valueCopyright © 2023. All rights reserved.