typeof dateField gives JavaScript Error

When I use the following syntax:

typeof myDateField

I get the following (uncatchable) error:

org.mozilla.javascript.EvaluatorException: Invalid JavaScript value of type java.util.Date

So it seems the value of a datefield is not a JavaScript date but a Java date.
Is there anyway to check if a value is a Java date within JavaScript ?

Servoy 3.5.10

This is already fixed in Servoy 4.x

Any workaround for now ? I can’t upgrade a live system yet but I can push a quickfix (when possible).

instanceof Date

should work.

what do you expect typeof datefield gives you back?
“date” ?

that it doesnt do it will return “object” so you dont get very far. (even null will return “object”)

If you really want to know that it is a date you can do this:

if (datefield instanceof Date)
{
// xxx
}

Argghh patrick was just before me…

jcompagner:
what do you expect typeof datefield gives you back?

I used the example of a datefield, but it could also be a text field with a date or something. In my code I need to know what type of value it holds and process it accordingly.
All this is part of a workaround in 2.2.x to make sure a search in related tables (1 or 2 deep) doesn’t result in double parent records. I.e. I had to reproduce Servoy’s search functionality.

Anyway, thanks Patrick and Johan! Got the fix working.

Edit: I meant version 2.2.x, not 3.x