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
This commit is contained in:
David Huynh 2011-09-01 22:11:45 +00:00
parent 98c268d9f7
commit 57c11d0238

View File

@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.expr.functions; package com.google.refine.expr.functions;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Properties; import java.util.Properties;
@ -53,11 +54,16 @@ public class ToDate implements Function {
// missing value, can this happen? // missing value, can this happen?
return null; 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 // ignore cell values that aren't strings
return null; return null;
} }
String o1 = (String) args[0]; String o1 = (String) arg0;
// "o, boolean month_first (optional)" // "o, boolean month_first (optional)"
if (args.length == 1 || (args.length == 2 && args[1] instanceof Boolean)) { if (args.length == 1 || (args.length == 2 && args[1] instanceof Boolean)) {