public class NumberParser
extends java.lang.Object
No method will throw any sort of Exception when parsing a string. All methods accept any Java String or null as legal input, if the input is non null, whitespace will be trimmed first, and then parsing will be attempted.
:TODO: Add Integer, Float, and Double methods as needed.
Modifier and Type | Method and Description |
---|---|
static java.lang.Float |
parseFloat(java.lang.String str)
Parse a Float from a String without exceptions.
|
static float |
parseFloat(java.lang.String str,
float def)
Parse a float from a String, with a default value
|
static java.lang.Integer |
parseInt(java.lang.String str)
Parse an Integer from a String.
|
static java.lang.Long |
parseLong(java.lang.String str)
Parses a Long out of a string.
|
static long |
parseLong(java.lang.String str,
long def)
Parses a long out of a string.
|
public static java.lang.Long parseLong(java.lang.String str)
str
- string to parse for a Long.public static java.lang.Integer parseInt(java.lang.String str)
str
- the String to parsepublic static java.lang.Float parseFloat(java.lang.String str)
str
- the String to parsepublic static float parseFloat(java.lang.String str, float def)
str
- def
- the value to return if the String cannot be parsedpublic static long parseLong(java.lang.String str, long def)
str
- string to parse for a long.def
- default value to return if it is not possible to parse the the string.