diff --git a/src/main/java/com/metaweb/gridworks/commands/util/PreviewExpressionCommand.java b/src/main/java/com/metaweb/gridworks/commands/util/PreviewExpressionCommand.java index 4e4e5c0ec..9e3811083 100644 --- a/src/main/java/com/metaweb/gridworks/commands/util/PreviewExpressionCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/util/PreviewExpressionCommand.java @@ -2,6 +2,7 @@ package com.metaweb.gridworks.commands.util; import java.io.IOException; import java.io.Serializable; +import java.util.Calendar; import java.util.Properties; import javax.servlet.ServletException; @@ -21,6 +22,7 @@ import com.metaweb.gridworks.expr.ParsingException; import com.metaweb.gridworks.model.Cell; import com.metaweb.gridworks.model.Project; import com.metaweb.gridworks.model.Row; +import com.metaweb.gridworks.util.ParsingUtilities; public class PreviewExpressionCommand extends Command { @@ -103,8 +105,16 @@ public class PreviewExpressionCommand extends Command { writer.key("message"); writer.value(((EvalError) result).message); writer.endObject(); } else { - if (result != null && result instanceof HasFields) { - result = "[object " + result.getClass().getSimpleName() + "]"; + if (result != null) { + if (result instanceof HasFields) { + result = "[object " + result.getClass().getSimpleName() + "]"; + } else if (result instanceof Calendar) { + Calendar c = (Calendar) result; + + result = "[object " + + result.getClass().getSimpleName() + " " + + ParsingUtilities.dateToString(c.getTime()) +"]"; + } } writer.value(result); } diff --git a/src/main/java/com/metaweb/gridworks/model/Cell.java b/src/main/java/com/metaweb/gridworks/model/Cell.java index 2d3808db9..abe6d0799 100644 --- a/src/main/java/com/metaweb/gridworks/model/Cell.java +++ b/src/main/java/com/metaweb/gridworks/model/Cell.java @@ -1,6 +1,7 @@ package com.metaweb.gridworks.model; import java.io.Serializable; +import java.util.Calendar; import java.util.Properties; import org.json.JSONException; @@ -10,6 +11,7 @@ import com.metaweb.gridworks.Jsonizable; import com.metaweb.gridworks.expr.EvalError; import com.metaweb.gridworks.expr.ExpressionUtils; import com.metaweb.gridworks.expr.HasFields; +import com.metaweb.gridworks.util.ParsingUtilities; public class Cell implements Serializable, HasFields, Jsonizable { private static final long serialVersionUID = -5891067829205458102L; @@ -38,7 +40,11 @@ public class Cell implements Serializable, HasFields, Jsonizable { writer.value(((EvalError) value).message); } else { writer.key("v"); - writer.value(value); + if (value != null && value instanceof Calendar) { + writer.value(ParsingUtilities.dateToString(((Calendar) value).getTime())); + } else { + writer.value(value); + } } if (recon != null) {