public static String retrieveCloneName ( String bcName , Date now ) { String bcNameToAppend = "" ; int index = bcName . indexOf ( "_" ) ; if ( index == - 1 ) { // No '_' was found, need to append date prefix to whole bcName bcNameToAppend = bcName ; } else { // A '_' char was found, need to analyze if the prefix is a date (to // be replaced with new one) String prefix = bcName . substring ( 0 , index ) ; if ( prefix . length ( ) == CLONE_PREFIX_DATE_FORMAT . length ( ) ) { try { new SimpleDateFormat ( CLONE_PREFIX_DATE_FORMAT ) . parse ( prefix ) ; // The prefix was a date, need to append new date to a substring // of original bcName bcNameToAppend = bcName . substring ( index + 1 ) ; } catch ( ParseException ex ) { // The prefix was not a date, need to append date prefix to // whole bcName bcNameToAppend = bcName ; } } else { bcNameToAppend = bcName ; } } StringBuilder sb = new StringBuilder ( ) ; sb . append ( new SimpleDateFormat ( CLONE_PREFIX_DATE_FORMAT ) . format ( now ) ) . append ( "_" ) . append ( bcNameToAppend ) ; return sb . toString ( ) ; }
Change the BC clone name into date_original - BC - name where date will be for every clone updated and for original BC names will be added .