Closed
Bug 647173
Opened 14 years ago
Closed 6 years ago
The Context.jsToJava() method can not convert some JS Date objects to correct java.uti.Date objects.
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
INACTIVE
People
(Reporter: dlut_zxf, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16
Build Identifier: 1.7.2
These JS Date objects are created by "new Date( 0, i, 1 )" and i is an integer value between 0 and 11. But the Context.jsToJava( jsDate, java.util.Date ) will return error results between 4 and 10. It seems that this is a daylight time issue.
Reproducible: Always
Steps to Reproduce:
Followed code can be used to reproduce this bug
import javax.script.ScriptException;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
public class TestRhinoDate
{
public static void main(String[] args) throws ScriptException
{
Context cx = Context.enter();
try
{
Scriptable scope = cx.initStandardObjects();
for( int i = 0; i < 12; i++ )
{
String str = "new Date( 0, " + i + ", 1 )";
Object value = cx.evaluateString( scope, str, "<inline>", 1, null );
System.out.println( Context.jsToJava( value, java.util.Date.class ) );
}
}
finally
{
Context.exit();
}
}
}
Actual Results:
Mon Jan 01 00:00:00 PST 1900
Thu Feb 01 00:00:00 PST 1900
Thu Mar 01 00:00:00 PST 1900
Sun Apr 01 00:00:00 PST 1900
Mon Apr 30 23:00:00 PST 1900
Thu May 31 23:00:00 PST 1900
Sat Jun 30 23:00:00 PST 1900
Tue Jul 31 23:00:00 PST 1900
Fri Aug 31 23:00:00 PST 1900
Sun Sep 30 23:00:00 PST 1900
Thu Nov 01 00:00:00 PST 1900
Sat Dec 01 00:00:00 PST 1900
Expected Results:
Mon Jan 01 00:00:00 PST 1900
Thu Feb 01 00:00:00 PST 1900
Thu Mar 01 00:00:00 PST 1900
Sun Apr 01 00:00:00 PST 1900
Tue May 01 00:00:00 PST 1900
Fri Jun 01 00:00:00 PST 1900
Sun Jul 01 00:00:00 PST 1900
Wed Aug 01 00:00:00 PST 1900
Sat Sep 01 00:00:00 PST 1900
Mon Oct 01 00:00:00 PST 1900
Thu Nov 01 00:00:00 PST 1900
Sat Dec 01 00:00:00 PST 1900
Comment 2•13 years ago
|
||
java.util.Date applies DST using the "tz database" whereas Rhino applies DST for years before 1970 by using the EquivalentYear mapping described in the ECMAScript5 spec. See bug 351066 for more background information.
Comment 3•6 years ago
|
||
Closing. Bug management is now done here:
https://github.com/mozilla/rhino
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
You need to log in
before you can comment on or make changes to this bug.
Description
•