Closed Bug 201326 Opened 22 years ago Closed 22 years ago

Rhino should be able to coerce JavaScript Date to Java Date

Categories

(Rhino Graveyard :: Core, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: hannesw, Assigned: norrisboyd)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030210 Build Identifier: Rhino 1.5R4 Rhino does not coerce JavaScript Date objects to Java Date objects when calling Java methods that take java.util.Date as parameter. I think that coercion would be both quite simple and useful. Reproducible: Always Steps to Reproduce: js> var d = new Date(); js> var f = new java.text.SimpleDateFormat(); js> f.format(d); js: "<stdin>", line 18: uncaught JavaScript exception: java.lang.IllegalArgumentException: Cannot format given Object as a Date
cc'ing Igor -
Summary: rhino should be able to coerce JavaScript Date to Java Date → Rhino should be able to coerce JavaScript Date to Java Date
I've found the problem fairly easy to fix. This patch works well for me, would be nice if it was applied to CVS.
The patch changes includes the new DataClass field in ScriptRuntime to use it in NativeJavaObject, a direct access method to NativeDate time and if-sequence optimization in coerceType.
Attachment #120192 - Attachment is obsolete: true
I commited the above patch: js> var d = new Date(); js> var f = new java.text.SimpleDateFormat(); js> f.format(d); 4/12/03 12:49 PM
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified FIXED: ------------------------------ BEFORE ------------------------------ js> var d = new Date(); js> var f = new java.text.SimpleDateFormat(); js> f.format(d); js: "<stdin>", line 3: uncaught JavaScript exception: java.lang.IllegalArgumentException: Cannot format given Object as a Date ------------------------------ AFTER ------------------------------- js> var d = new Date(); js> var f = new java.text.SimpleDateFormat(); js> f.format(d); 4/12/03 6:14 PM
Status: RESOLVED → VERIFIED
Targeting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: