Parse org.mozilla.javascript.NativeDate in Java.util.Date

I am trying to parse the date I get from a JavaScript script evaluated using the rhino library into java.util.Date, can I convert org.mozilla.javascript.NativeDate to java.util.Date?

If I convert NativeDate to a string using the Context.tostring method, I get the date in the following format:

Wed Oct 12 2011 16:17:59 GMT+0200 (CEST)

How can I parse this string date representation into a java.util.Date object?

+5
source share
3 answers

In the rhino

context.jsToJava(nativeDateObj, Date.class);

+6
source

Bvesco . (java to js) - Context.javaTojs() . - javascript:

Object js = context.newObject(scope, "Date", new Object[] {date.getTime()});

js java ( ):

Date date = new Date((long) ScriptRuntime.toNumber(s)); 
+3

You tried?

java.sql.Date.valueOf("date string");
-2
source

All Articles