我正在使用 Javascript 引擎来比较值。值可以是双精度或日期。(字符串)
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");
}
上面的代码适用于 double 值,但给出了错误的日期结果。对于上面的示例,它应该显示 TRUE,但它显示 FALSE。请帮忙。