/** * @return The card number string consisting of all but the last four digits replaced with bullet * ('•'). */ public String getRedactedCardNumber() { if (cardNumber != null) { String redacted = ""; if (cardNumber.length() > 4) { redacted += String.format("%" + (cardNumber.length() - 4) + "s", "").replace(' ', '\u2022'); } redacted += getLastFourDigitsOfCardNumber(); return CreditCardNumber.formatString(redacted, false, CardType.fromCardNumber(cardNumber)); } else { return ""; } }
/** @return A string suitable for display, with spaces inserted for readability. */ public String getFormattedCardNumber() { return CreditCardNumber.formatString(cardNumber); }