I am using Javascript engine to compare values. Values can be double or date. (strings)
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
// Date value is populated dynamically here
engine.eval("dateValue = " + "01/02/2012");
// The condition is populated dynamically here
if ((Boolean) engine.eval("dateValue <=" + "12/31/2012")) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}
The above code works fine with double values, but gives wrong results with dates. For the above example it should display TRUE, but it displays FALSE. Please help.
You should do something like:
In your script 12/31/2012 will be interpreted as a mathematical expression.
another possibility for the test you wanna do is something like: