private String addSpaceToCardNumber(){
  final int splitBy=4;
  final int length=mCardNumber.length();
  if (length % splitBy != 0 || length <= splitBy) {
    return mCardNumber;
  }
 else {
    final StringBuilder result=new StringBuilder();
    result.append(mCardNumber.substring(0,splitBy));
    for (int i=splitBy; i < length; i++) {
      if (i % splitBy == 0) {
        result.append(" ");
      }
      result.append(mCardNumber.charAt(i));
    }
    return result.toString();
  }
}

private String addSpaceToCardNumber ( ) { final int splitBy = 4 ; final int length = mCardNumber . length ( ) ; if ( length % splitBy != 0 || length <= splitBy ) { return mCardNumber ; } else { final StringBuilder result = new StringBuilder ( ) ; result . append ( mCardNumber . substring ( 0 , splitBy ) ) ; for ( int i = splitBy ; i < length ; i ++ ) { if ( i % splitBy == 0 ) { result . append ( " " ) ; } result . append ( mCardNumber . charAt ( i ) ) ; } return result . toString ( ) ; } }
adds space after every 4 characters to the card number if the card number is divisible by 4
