public class FormatUtil extends Object
Modifier and Type | Field | Description |
---|---|---|
static int |
DECIMAL_DIGITS_TO_PRINT |
Constructor | Description |
---|---|
FormatUtil() |
Constructs a new FormatUtil and initializes various internal formatters.
|
Modifier and Type | Method | Description |
---|---|---|
String |
format(boolean value) |
Formats a boolean value to a String.
|
String |
format(char value) |
Formats a char as a string.
|
String |
format(double value) |
Formats a double to a floating point string.
|
String |
format(float value) |
Formats a float to a floating point string.
|
String |
format(int value) |
Formats an int to an integer string.
|
String |
format(long value) |
Formats a long to an integer string.
|
String |
format(short value) |
Formats a short to an integer string.
|
String |
format(Iso8601Date value) |
Formats date & time
|
String |
format(Enum value) |
Formats an enum to the String representation of an enum.
|
String |
format(Object value) |
Attempts to determine the type of value and format it appropriately.
|
String |
format(Date value) |
Formats a date to a date string without time.
|
boolean |
parseBoolean(String value) |
Parses a String into a boolean, as per the above convention that true = Y and false = N.
|
char |
parseChar(String value) |
Parses a String into a char.
|
Date |
parseDate(String value) |
Parses a String into a date.
|
double |
parseDouble(String value) |
Parses a String into a double.
|
<E extends Enum> |
parseEnum(String value,
Class<E> type) |
Parses a String into an Enum of the given type.
|
float |
parseFloat(String value) |
Parses a String into a float.
|
int |
parseInt(String value) |
Parses a String into an int.
|
Iso8601Date |
parseIso8601Date(String value) |
Parse a String into an Iso8601 Date
|
long |
parseLong(String value) |
Parses a String into a long.
|
Object |
parseObject(String value,
Class<?> returnType) |
Attempts to determine the correct parse method to call based on the desired
return type and then parses the String and returns the value.
|
short |
parseShort(String value) |
Parses a String into a short.
|
public static final int DECIMAL_DIGITS_TO_PRINT
public FormatUtil()
public String format(short value)
public String format(int value)
public String format(long value)
public String format(float value)
public String format(double value)
public String format(char value)
public String format(Iso8601Date value)
public String format(boolean value)
public String format(Object value)
public short parseShort(String value)
public int parseInt(String value)
public long parseLong(String value)
public float parseFloat(String value)
public double parseDouble(String value)
public <E extends Enum> E parseEnum(String value, Class<E> type)
public Iso8601Date parseIso8601Date(String value)
public boolean parseBoolean(String value)
public char parseChar(String value)
public Object parseObject(String value, Class<?> returnType)
value
- the String value to be parsedreturnType
- the desired return type