private String convert ( String str , String dateFormat ) { String ret = str ; // Carry out the required string conversion long longValue = 0L ; double doubleValue = 0.0d ; // Convert the input value to a number if ( str . length ( ) > 0 ) { if ( inputType == INTEGER_TYPE || inputType == NUMBER_TYPE ) longValue = Long . parseLong ( str ) ; else if ( inputType == DECIMAL_TYPE || inputType == SECONDS_TYPE ) doubleValue = Double . parseDouble ( str ) ; else if ( inputType == DATETIME_TYPE && inputFormat . length ( ) > 0 ) longValue = parseDateTime ( str , inputFormat ) ; } // Convert seconds to milliseconds if ( inputType == SECONDS_TYPE ) doubleValue *= 1000.0d ; // Allow for cross type conversions // eg. decimal->datetime, seconds->datetime if ( inputType == DECIMAL_TYPE || inputType == SECONDS_TYPE ) longValue = ( long ) doubleValue ; else doubleValue = ( double ) longValue ; // Convert the number to the output format if ( outputType == INTEGER_TYPE ) ret = Long . toString ( longValue ) ; else if ( outputType == DECIMAL_TYPE || outputType == SECONDS_TYPE ) ret = convertDecimal ( doubleValue , outputFormat ) ; else if ( outputType == DATETIME_TYPE ) ret = convertDateTime ( longValue , outputFormat . length ( ) > 0 ? outputFormat : dateFormat ) ; else if ( outputType == STRING_TYPE ) ret = convertString ( str , outputFormat , regex ) ; return ret ; }
Convert the given string using the defined input and output formats and types .