public static String findReplacement ( final String variableName , final Date date ) { if ( variableName . equalsIgnoreCase ( "date" ) ) { return cleanUpName ( DateFormat . getDateInstance ( ) . format ( date ) ) ; } else if ( variableName . equalsIgnoreCase ( "datetime" ) ) { return cleanUpName ( DateFormat . getDateTimeInstance ( ) . format ( date ) ) ; } else if ( variableName . equalsIgnoreCase ( "time" ) ) { return cleanUpName ( DateFormat . getTimeInstance ( ) . format ( date ) ) ; } else { try { return new SimpleDateFormat ( variableName ) . format ( date ) ; } catch ( Exception e ) { LOGGER . error ( "Unable to format timestamp according to pattern: {}" , variableName , e ) ; return "${" + variableName + "}" ; } } }
Update a variable name with a date if the variable is detected as being a date .