1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| private String doConvertToString(Map<String, Object> context, Object value) {
String result = null;
if (value instanceof int[]) {
int[] x = (int[]) value;
List<Integer> intArray = new ArrayList<Integer>(x.length);
for (int aX : x) {
intArray.add(Integer.valueOf(aX));
}
result = TextUtils.join(", ", intArray);
} else if (value instanceof long[]) {
long[] x = (long[]) value;
List<Long> longArray = new ArrayList<Long>(x.length);
for (long aX : x) {
longArray.add(Long.valueOf(aX));
}
result = TextUtils.join(", ", longArray);
} else if (value instanceof double[]) {
double[] x = (double[]) value;
List<Double> doubleArray = new ArrayList<Double>(x.length);
for (double aX : x) {
doubleArray.add(new Double(aX));
}
result = TextUtils.join(", ", doubleArray);
} else if (value instanceof boolean[]) {
boolean[] x = (boolean[]) value;
List<Boolean> booleanArray = new ArrayList<Boolean>(x.length);
for (boolean aX : x) {
booleanArray.add(new Boolean(aX));
}
result = TextUtils.join(", ", booleanArray);
} else if (value instanceof Date) {
DateFormat df = null;
if (value instanceof java.sql.Time) {
df = DateFormat.getTimeInstance(DateFormat.MEDIUM, getLocale(context));
} else if (value instanceof java.sql.Timestamp) {
SimpleDateFormat dfmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.MEDIUM,
getLocale(context));
df = new SimpleDateFormat(dfmt.toPattern() + MILLISECOND_FORMAT);
} else {
df = DateFormat.getDateInstance(DateFormat.SHORT, getLocale(context));
}
result = df.format(value);
} else if (value instanceof String[]) {
result = TextUtils.join(", ", (String[]) value);
}
return result;
} |
Partager