private fun bindCreditCardExpiryDate( creditCard: CreditCard, binding: CreditCardListItemBinding, ) { val dateFormat = SimpleDateFormat(DATE_PATTERN, Locale.getDefault()) val calendar = Calendar.getInstance() calendar.set(Calendar.DAY_OF_MONTH, 1) // Subtract 1 from the expiry month since Calendar.Month is based on a 0-indexed. calendar.set(Calendar.MONTH, creditCard.expiryMonth.toInt() - 1) calendar.set(Calendar.YEAR, creditCard.expiryYear.toInt()) binding.expiryDate.text = dateFormat.format(calendar.time) }
Set the credit card expiry date formatted according to the locale.