# java.lang.RuntimeException when using dates in objects

**URL:** <https://forum.servoy.com/t/java-lang-runtimeexception-when-using-dates-in-objects/6301>\
**Category:** Classic Servoy\
**Created:** [July 31, 2006, 3:54pm UTC](https://forum.servoy.com/t/java-lang-runtimeexception-when-using-dates-in-objects/6301 "2006-07-31T15:54:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [July 31, 2006, 3:54pm UTC](https://forum.servoy.com/t/java-lang-runtimeexception-when-using-dates-in-objects/6301/1 "2006-07-31T15:54:18Z")

</div>

Hello,

I have the following code:

```auto
var vRecordOld = foundset.getRecord(1);
var vRecordNew = foundset.getRecord(2);

var vDifferentFields = new Array();
for ( var vField in vRecordOld )
{
	if (vRecordOld[vField] != vRecordNew[vField]) {
		vDifferentFields[vDifferentFields.length] = vField;
	}
}

```

At the point where vField is a date field, I get this error:

> java.lang.RuntimeException  
> at org.mozilla.javascript.ScriptRuntime.eq(ScriptRuntime.java:1657)  
> at org.mozilla.javascript.Interpreter.do\_eq(Interpreter.java:2602)  
> at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1649)  
> at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:94)  
> at com.servoy.j2db.scripting.e.call(Unknown Source)  
> at com.servoy.j2db.develop.debugger.k.a(Unknown Source)  
> at com.servoy.j2db.develop.debugger.k.executeFunction(Unknown Source)  
> at com.servoy.j2db.FormPanel.a(Unknown Source)  
> at com.servoy.j2db.FormPanel.a(Unknown Source)  
> at com.servoy.j2db.develop.debugger.k$h.actionPerformed(Unknown Source)  
> at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)  
> at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)  
> at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)  
> at javax.swing.DefaultButtonModel.setPressed(Unknown Source)  
> at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)  
> at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)  
> at java.awt.Component.processMouseEvent(Unknown Source)  
> at javax.swing.JComponent.processMouseEvent(Unknown Source)  
> at java.awt.Component.processEvent(Unknown Source)  
> at java.awt.Container.processEvent(Unknown Source)  
> at java.awt.Component.dispatchEventImpl(Unknown Source)  
> at java.awt.Container.dispatchEventImpl(Unknown Source)  
> at java.awt.Component.dispatchEvent(Unknown Source)  
> at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)  
> at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)  
> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)  
> at java.awt.Container.dispatchEventImpl(Unknown Source)  
> at java.awt.Window.dispatchEventImpl(Unknown Source)  
> at java.awt.Component.dispatchEvent(Unknown Source)  
> at java.awt.EventQueue.dispatchEvent(Unknown Source)  
> at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)  
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)  
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
> at java.awt.EventDispatchThread.run(Unknown Source)

I have played with this a little more and tried this code:

```auto
var vObject = new Object();
vObject.date1 = new Date();
vObject.date2 = new Date();
if (vObject.vDate1 != vObject.vDate2) {
	application.output('These dates are not the same');
}
else {
	application.output('Servoy thinks these dates are the same. Difference in ms is: ' + (vObject.date2 - vObject.date1));
}

```

If you debug slowly you get this output:

> Servoy thinks these dates are the same. Difference in ms is: 860

Am I misunderstanding something fundamental or is this a bug?

Thanks  
Patrick

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [July 31, 2006, 4:42pm UTC](https://forum.servoy.com/t/java-lang-runtimeexception-when-using-dates-in-objects/6301/2 "2006-07-31T16:42:24Z")

</div>

One more remark: extracting the record’s fields doesn’t heal the problem.

So this code:

```auto
var vOldValue = vRecordOld[vField];
var vNewValue = vRecordNew[vField];
if (vOldValue != vNewValue)

```

doesn’t work either.

Could anyone help me to compare two records like this?

Thanks  
Patrick
