feat(can-payment): 다국적 통화 표기 지원 및 결제 금액 표시 개선
- KRW 고정 표기에서 벗어나 PG/해외 결제 등 다양한 통화 표기를 정확히 지원하기 위함
This commit is contained in:
@@ -3,7 +3,9 @@ package kr.co.vividnext.sodalive.extensions
|
||||
import android.graphics.Typeface
|
||||
import android.text.SpannableString
|
||||
import kr.co.vividnext.sodalive.common.CustomTypefaceSpan
|
||||
import java.text.NumberFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Currency
|
||||
import java.util.Locale
|
||||
|
||||
fun String.convertDateFormat(
|
||||
@@ -54,3 +56,14 @@ fun String.prefix(length: Int): String {
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
fun String.formatMoney(currencyCode: String, locale: Locale = Locale.getDefault()): String {
|
||||
val newCurrency = Currency.getInstance(currencyCode)
|
||||
val nf = NumberFormat.getCurrencyInstance(locale).apply {
|
||||
currency = newCurrency
|
||||
minimumFractionDigits = newCurrency.defaultFractionDigits
|
||||
maximumFractionDigits = newCurrency.defaultFractionDigits
|
||||
}
|
||||
val bd = this.toBigDecimal()
|
||||
return nf.format(bd)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user