Java Utililty Methods String to

List of utility methods to do String to

Description

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

Method

StringconvertStringArrayToString(String[] a_asStrings, String a_sDelim)
Takes an array of Strings and turns them in to a comma delimited list of strings in a string.
StringBuffer sb = new StringBuffer("");
if ((a_asStrings != null) && (a_asStrings.length > 0)) {
    sb.append(a_asStrings[0]);
    if (a_asStrings.length > 1) {
        for (int i = 1; i < a_asStrings.length; i++) {
            sb.append(a_sDelim + a_asStrings[i]);
return (sb.toString());
StringconvertStringArrayToString(String[] value, String separator)
convert String Array To String
if (value.length == 0) {
    return "";
StringBuilder sb = new StringBuilder();
for (String v : value) {
    sb.append(v);
    sb.append(separator);
sb.setLength(sb.length() - separator.length());
return sb.toString();
StringconvertStringFormat(String property)
convert String Format
if (property == null)
    return null;
if (ZIP.equals(property))
    return ZIP_CODE;
if (PHONE.equals(property))
    return PHONE_CODE;
if (SOCIAL.equals(property))
    return SOCIALNUMBER_CODE;
...
StringconvertStringsToTextSet(String[] values)
convert Strings To Text Set
if (null == values)
    return null;
String returnValue = "";
for (int i = 0; i < values.length; i++) {
    if (i == 0)
        returnValue += values[i];
    else
        returnValue += "," + values[i];
...
int[]convertStringToArray(String str)
convert String To Array
int[] A = new int[str.length()];
for (int i = 0; i < A.length; i++) {
    A[A.length - i - 1] = Integer.parseInt(str.substring(i, i + 1));
return A;
ColorconvertStringToColor(String color)
convert String To Color
Color colorConverted = Color.black; 
if (color.equals("black")) {
    colorConverted = Color.black;
if (color.equals("red")) {
    colorConverted = Color.red;
if (color.equals("blue")) {
...
EConvertStringToEnumValue(String enumAsString, Class type)
Convert String To Enum Value
E userType = Enum.valueOf(type, enumAsString.toUpperCase());
return userType;
floatconvertStringToFloat(String str)
convert String To Float
float val = 0;
if (str != null || !str.isEmpty()) {
    val = Float.parseFloat(str);
return val;
StringconvertStringToId(String s)
convert String To Id
StringBuilder sb = new StringBuilder(s.length());
for (int i = 0; i != s.length(); i++) {
    char c = s.charAt(i);
    if (Character.isLetterOrDigit(c)) {
        sb.append(c);
return sb.toString().toLowerCase();
...
intconvertStringToIntDef(String string, int defaultValue)
Get the parsed string as int or defaultValue if an exception occured
try {
    return Integer.parseInt(string);
} catch (NumberFormatException e) {
    return defaultValue;