public static String generateClientIdWithTimestamp(final String clientId,final ProtocolVersionEnum protocol){
  final int addedLength=CLIENT_ID_TIMESTAMP_FORMAT.length() + CLIENT_ID_TIMESTAMP_DELIMITER.length();
  final int index=clientId.lastIndexOf(CLIENT_ID_TIMESTAMP_DELIMITER);
  String newClientId=clientId;
  if (index >= 0 && (index + addedLength == newClientId.length())) {
    newClientId=newClientId.substring(0,index);
  }
  if (limitClientId(protocol) && newClientId.length() + addedLength > MAX_CLIENT_LENGTH_FOR_3_1) {
    newClientId=newClientId.substring(0,MAX_CLIENT_LENGTH_FOR_3_1 - addedLength);
  }
  newClientId=newClientId + CLIENT_ID_TIMESTAMP_DELIMITER + CLIENT_ID_SDF.format(new Date());
  return newClientId;
}

public static String generateClientIdWithTimestamp ( final String clientId , final ProtocolVersionEnum protocol ) { final int addedLength = CLIENT_ID_TIMESTAMP_FORMAT . length ( ) + CLIENT_ID_TIMESTAMP_DELIMITER . length ( ) ; final int index = clientId . lastIndexOf ( CLIENT_ID_TIMESTAMP_DELIMITER ) ; String newClientId = clientId ; if ( index >= 0 && ( index + addedLength == newClientId . length ( ) ) ) { newClientId = newClientId . substring ( 0 , index ) ; } if ( limitClientId ( protocol ) && newClientId . length ( ) + addedLength > MAX_CLIENT_LENGTH_FOR_3_1 ) { newClientId = newClientId . substring ( 0 , MAX_CLIENT_LENGTH_FOR_3_1 - addedLength ) ; } newClientId = newClientId + CLIENT_ID_TIMESTAMP_DELIMITER + CLIENT_ID_SDF . format ( new Date ( ) ) ; return newClientId ; }
generate client id with timestamp .
