Java Utililty Methods String Value Of

List of utility methods to do String Value Of

Description

The list of methods to do String Value Of are organized into topic(s).

Method

EvalueOf(final Class enumType, final String name)
Returns the enum constant of the specified enum type with the specified name.
try {
    return Enum.valueOf(enumType, name);
} catch (final IllegalArgumentException e) {
    return null;
} catch (final NullPointerException e) {
    return null;
StringvalueOf(final Object obj, final String defaultValue)

 Assertions : assertNull(StringHelper.valueOf(null, null)); assertEquals("", StringHelper.valueOf(null, "")); assertEquals("a", StringHelper.valueOf(null, "a")); assertEquals("foo", StringHelper.valueOf("foo", "a")); 

if (obj == null) {
    return defaultValue;
} else {
    return String.valueOf(obj);
StringvalueOf(Object object, String defaultEmptyValue)
value Of
if (object == null) {
    return defaultEmptyValue;
return String.valueOf(object);
booleanvalueOf(String boolStr)
Return the boolean value of an xsd:boolean type of DOM element/attribute.
return "true".equals(boolStr) || "1".equals(boolStr);
intvalueOf(String decimal)
value Of
int index = decimal.indexOf(".");
if (index > 0) {
    decimal = decimal.substring(0, index);
return Integer.valueOf(decimal);
StringvalueOf(String first, String defaultstr)
returns the value of the first parameter if set, otherwise a default value
if ((first != null) && (first.length() > 0)) {
    return first;
return defaultstr;
doublevalueOf(String format, String value)
value Of
double temp = Double.valueOf(value);
return Double.valueOf(String.format(format, temp));
intvalueOf(String s)
value Of
if (!isNumeric(s)) {
    return 0;
} else {
    return Integer.valueOf(s);
LongvalueOf(String s)
value Of
try {
    return (Long.valueOf(s));
} catch (Exception e) {
    return 0L;
intvalueOf(String s)
value Of
return !isNumeric(s) ? 0 : Integer.valueOf(s).intValue();