@Test public void testTruncDate() { Date dateBase = new Date( 118, Calendar.FEBRUARY, 15, 11, 11, 11 ); Calendar c = Calendar.getInstance(); c.set( 2011, Calendar.NOVEMBER, 11, 11, 11, 11 ); c.set( Calendar.MILLISECOND, 11 ); Date rtn = null; Calendar c2 = Calendar.getInstance(); rtn = ScriptAddedFunctions.truncDate( dateBase, 5 ); c2.setTime( rtn ); Assert.assertEquals( Calendar.JANUARY, c2.get( Calendar.MONTH ) ); rtn = ScriptAddedFunctions.truncDate( dateBase, 4 ); c2.setTime( rtn ); Assert.assertEquals( 1, c2.get( Calendar.DAY_OF_MONTH ) ); rtn = ScriptAddedFunctions.truncDate( dateBase, 3 ); c2.setTime( rtn ); Assert.assertEquals( 0, c2.get( Calendar.HOUR_OF_DAY ) ); rtn = ScriptAddedFunctions.truncDate( dateBase, 2 ); c2.setTime( rtn ); Assert.assertEquals( 0, c2.get( Calendar.MINUTE ) ); rtn = ScriptAddedFunctions.truncDate( dateBase, 1 ); c2.setTime( rtn ); Assert.assertEquals( 0, c2.get( Calendar.SECOND ) ); rtn = ScriptAddedFunctions.truncDate( dateBase, 0 ); c2.setTime( rtn ); Assert.assertEquals( 0, c2.get( Calendar.MILLISECOND ) ); try { ScriptAddedFunctions.truncDate( rtn, 6 ); Assert.fail( "Expected exception - passed in level > 5 to truncDate" ); } catch ( Exception expected ) { } try { ScriptAddedFunctions.truncDate( rtn, -7 ); Assert.fail( "Expected exception - passed in level < 0 to truncDate" ); } catch ( Exception expected ) { } }
@SuppressWarnings( "fallthrough" ) public static Object truncDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 2 ) { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return undefinedValue; } java.util.Date dArg1 = null; Integer level = null; try { dArg1 = (java.util.Date) ArgList[0]; level = (Integer) ArgList[1]; } catch ( Exception e ) { throw new RuntimeException( e.toString() ); } return ScriptAddedFunctions.truncDate( dArg1, level ); } else { throw new RuntimeException( "The function call truncDate requires 2 arguments: a date and a level (int)" ); } }
ScriptAddedFunctions { @SuppressWarnings( "fallthrough" ) public static Object truncDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 2 ) { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return undefinedValue; } java.util.Date dArg1 = null; Integer level = null; try { dArg1 = (java.util.Date) ArgList[0]; level = (Integer) ArgList[1]; } catch ( Exception e ) { throw new RuntimeException( e.toString() ); } return ScriptAddedFunctions.truncDate( dArg1, level ); } else { throw new RuntimeException( "The function call truncDate requires 2 arguments: a date and a level (int)" ); } } }
ScriptAddedFunctions { @SuppressWarnings( "fallthrough" ) public static Object truncDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 2 ) { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return undefinedValue; } java.util.Date dArg1 = null; Integer level = null; try { dArg1 = (java.util.Date) ArgList[0]; level = (Integer) ArgList[1]; } catch ( Exception e ) { throw new RuntimeException( e.toString() ); } return ScriptAddedFunctions.truncDate( dArg1, level ); } else { throw new RuntimeException( "The function call truncDate requires 2 arguments: a date and a level (int)" ); } }  }
ScriptAddedFunctions { @SuppressWarnings( "fallthrough" ) public static Object truncDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 2 ) { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return undefinedValue; } java.util.Date dArg1 = null; Integer level = null; try { dArg1 = (java.util.Date) ArgList[0]; level = (Integer) ArgList[1]; } catch ( Exception e ) { throw new RuntimeException( e.toString() ); } return ScriptAddedFunctions.truncDate( dArg1, level ); } else { throw new RuntimeException( "The function call truncDate requires 2 arguments: a date and a level (int)" ); } }  static String getDigitsOnly( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static boolean LuhnCheck( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static int indexOf( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getTransformationName( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void appendToFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getFiscalDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static double getProcessCount( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void writeToLog( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object abs( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object ceil( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object floor( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getDayNumber( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isWorkingDay( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); @SuppressWarnings( "unused" ) static Object fireToDB( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object dateDiff( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getNextWorkingDay( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object dateAdd( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String fillString( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isCodepage( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String ltrim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String rtrim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String lpad( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String rpad( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object year( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object month( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object quarter( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object week( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object str2RegExp( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void touch( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object fileExists( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object str2date( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object date2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isRegExp( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void sendMail( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String upper( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String lower( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String num2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object str2num( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isNum( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object decode( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String replace( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String Alert( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void setEnvironmentVar( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getEnvironmentVar( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String trim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String substr( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String resolveIP( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void LoadScriptFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void LoadScriptFromTab( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void print( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void println( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); String getClassName(); static void setVariable( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getVariable( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static RowMetaInterface getOutputRowMeta( ScriptEngine actualContext, Bindings actualObject,
    Object[] ArgList, Object FunctionContext ); static RowMetaInterface getInputRowMeta( ScriptEngine actualContext, Bindings actualObject,
    Object[] ArgList, Object FunctionContext ); static Object[] createRowCopy( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void putRow( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void deleteFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void createFolder( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void copyFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static double getFileSize( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static boolean isFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static boolean isFolder( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getShortFilename( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getFileExtension( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getParentFoldername( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getLastModifiedTime( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object trunc( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); @SuppressWarnings( "fallthrough" ) static Object truncDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void moveFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); }
ScriptAddedFunctions { @SuppressWarnings( "fallthrough" ) public static Object truncDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext ) { if ( ArgList.length == 2 ) { if ( isNull( ArgList[0] ) ) { return null; } else if ( isUndefined( ArgList[0] ) ) { return undefinedValue; } java.util.Date dArg1 = null; Integer level = null; try { dArg1 = (java.util.Date) ArgList[0]; level = (Integer) ArgList[1]; } catch ( Exception e ) { throw new RuntimeException( e.toString() ); } return ScriptAddedFunctions.truncDate( dArg1, level ); } else { throw new RuntimeException( "The function call truncDate requires 2 arguments: a date and a level (int)" ); } }  static String getDigitsOnly( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static boolean LuhnCheck( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static int indexOf( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getTransformationName( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void appendToFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getFiscalDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static double getProcessCount( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void writeToLog( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object abs( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object ceil( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object floor( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getDayNumber( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isWorkingDay( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); @SuppressWarnings( "unused" ) static Object fireToDB( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object dateDiff( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object getNextWorkingDay( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object dateAdd( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String fillString( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isCodepage( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String ltrim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String rtrim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String lpad( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String rpad( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object year( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object month( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object quarter( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object week( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object str2RegExp( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void touch( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object fileExists( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object str2date( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object date2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isRegExp( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void sendMail( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String upper( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String lower( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String num2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object str2num( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isNum( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object isDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object decode( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String replace( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String Alert( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void setEnvironmentVar( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getEnvironmentVar( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String trim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String substr( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String resolveIP( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void LoadScriptFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void LoadScriptFromTab( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void print( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void println( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); String getClassName(); static void setVariable( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getVariable( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static RowMetaInterface getOutputRowMeta( ScriptEngine actualContext, Bindings actualObject,
    Object[] ArgList, Object FunctionContext ); static RowMetaInterface getInputRowMeta( ScriptEngine actualContext, Bindings actualObject,
    Object[] ArgList, Object FunctionContext ); static Object[] createRowCopy( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void putRow( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void deleteFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void createFolder( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void copyFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static double getFileSize( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static boolean isFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static boolean isFolder( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getShortFilename( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getFileExtension( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getParentFoldername( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static String getLastModifiedTime( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object trunc( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); @SuppressWarnings( "fallthrough" ) static Object truncDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static void moveFile( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ); static Object undefinedValue; static final long serialVersionUID; static final int STRING_FUNCTION; static final int NUMERIC_FUNCTION; static final int DATE_FUNCTION; static final int LOGIC_FUNCTION; static final int SPECIAL_FUNCTION; static final int FILE_FUNCTION; static String[] jsFunctionList; }