From 57c11d023829e6f77b5d60de6b957cc49205fa35 Mon Sep 17 00:00:00 2001 From: David Huynh Date: Thu, 1 Sep 2011 22:11:45 +0000 Subject: [PATCH] Fixed issue 442: Two column transforms to date on the same column turns the cells blank git-svn-id: http://google-refine.googlecode.com/svn/trunk@2230 7d457c2a-affb-35e4-300a-418c747d4874 --- main/src/com/google/refine/expr/functions/ToDate.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/src/com/google/refine/expr/functions/ToDate.java b/main/src/com/google/refine/expr/functions/ToDate.java index 24580148e..1058441d1 100644 --- a/main/src/com/google/refine/expr/functions/ToDate.java +++ b/main/src/com/google/refine/expr/functions/ToDate.java @@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.google.refine.expr.functions; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Properties; @@ -53,11 +54,16 @@ public class ToDate implements Function { // missing value, can this happen? return null; } - if (!(args[0] instanceof String)) { + Object arg0 = args[0]; + if (arg0 instanceof Date) { + return arg0; + } else if (arg0 instanceof Calendar) { + return ((Calendar) arg0).getTime(); + } else if (!(arg0 instanceof String)) { // ignore cell values that aren't strings return null; } - String o1 = (String) args[0]; + String o1 = (String) arg0; // "o, boolean month_first (optional)" if (args.length == 1 || (args.length == 2 && args[1] instanceof Boolean)) {