Return "null" for toString(null) - fixes #783
- also fixed grammar in error message
This commit is contained in:
parent
daed3bd90c
commit
f344e3da1c
@ -63,12 +63,12 @@ public class ToString implements Function {
|
||||
} else if (args.length == 1) {
|
||||
if (o1 instanceof String) {
|
||||
return (String) o1;
|
||||
} else if (o1 != null) {
|
||||
} else {
|
||||
return StringUtils.toString(o1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new EvalError("ToString accepts an object an optional second argument containing a date format string");
|
||||
return new EvalError("ToString accepts an object and an optional second argument containing a date format string");
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,6 +16,8 @@ public class StringUtils {
|
||||
if (o instanceof Calendar || o instanceof Date) {
|
||||
DateFormat formatter = DateFormat.getDateInstance();
|
||||
return formatter.format(o instanceof Date ? ((Date) o) : ((Calendar) o).getTime());
|
||||
} else if (o == null) {
|
||||
return "null";
|
||||
} else {
|
||||
return o.toString();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user