toString() should handle Date, too, rather than just Calendar.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1960 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-12-25 21:33:59 +00:00
parent f85e9198d4
commit 0ff40eabbd

View File

@ -36,6 +36,7 @@ package com.google.refine.expr.functions;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.Properties; import java.util.Properties;
import org.json.JSONException; import org.json.JSONException;
@ -49,6 +50,11 @@ public class ToString implements Function {
if (args.length >= 1) { if (args.length >= 1) {
Object o1 = args[0]; Object o1 = args[0];
if (o1 != null) { if (o1 != null) {
if (o1 instanceof Date) {
Calendar c = Calendar.getInstance();
c.setTime((Date) o1);
o1 = c;
}
if (o1 instanceof Calendar) { if (o1 instanceof Calendar) {
DateFormat formatter = null; DateFormat formatter = null;
if (args.length == 2) { if (args.length == 2) {