List of utility methods to do String to
String | convertStringArrayToString(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()); |
String | convertStringArrayToString(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(); |
String | convertStringFormat(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; ... |
String | convertStringsToTextSet(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; |
Color | convertStringToColor(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")) { ... |
E | ConvertStringToEnumValue(String enumAsString, Class Convert String To Enum Value E userType = Enum.valueOf(type, enumAsString.toUpperCase());
return userType;
|
float | convertStringToFloat(String str) convert String To Float float val = 0; if (str != null || !str.isEmpty()) { val = Float.parseFloat(str); return val; |
String | convertStringToId(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(); ... |
int | convertStringToIntDef(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; |