public static Date jsToDate( Object value, String classType ) throws KettleValueException {
    double dbl;
    if ( !classType.equalsIgnoreCase( JS_UNDEFINED ) ) {
      if ( classType.equalsIgnoreCase( "org.mozilla.javascript.NativeDate" ) ) {
        dbl = Context.toNumber( value );
      } else if ( classType.equalsIgnoreCase( JS_NATIVE_JAVA_OBJ )
        || classType.equalsIgnoreCase( "java.util.Date" ) ) {
        // Is it a java Date() class ?
        try {
          Date dat = (Date) Context.jsToJava( value, java.util.Date.class );
          dbl = dat.getTime();
        } catch ( Exception e ) {
          // Is it a Value?
          //
          return convertValueToDate( value );
        }
      } else if ( classType.equalsIgnoreCase( "java.lang.Double" ) ) {
        dbl = (Double) value;
      } else {
        String string = (String) Context.jsToJava( value, String.class );
        dbl = Double.parseDouble( string );
      }
      long lng = Math.round( dbl );
      return new Date( lng );
    }
    return null;
  }
@Test
  public void jsToDate_Undefined() throws Exception {
    assertNull( JavaScriptUtils.jsToDate( null, UNDEFINED ) );
  }