|
|
|
|
@ -2,6 +2,7 @@ package net.pokeranalytics.android.util.extensions |
|
|
|
|
|
|
|
|
|
import java.text.DecimalFormat |
|
|
|
|
import java.text.NumberFormat |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Double |
|
|
|
|
@ -18,11 +19,16 @@ fun Double.formatted(): String { |
|
|
|
|
return format.format(this) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun Double.toCurrency(): String { |
|
|
|
|
val format = NumberFormat.getCurrencyInstance() |
|
|
|
|
format.maximumFractionDigits = 2 |
|
|
|
|
format.minimumFractionDigits = 0 |
|
|
|
|
return format.format(this) |
|
|
|
|
fun Double.toCurrency(currency: Currency? = null): String { |
|
|
|
|
|
|
|
|
|
val currencyFormatter = NumberFormat.getCurrencyInstance() |
|
|
|
|
currency?.let { |
|
|
|
|
currencyFormatter.currency = currency |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
currencyFormatter.maximumFractionDigits = 2 |
|
|
|
|
currencyFormatter.minimumFractionDigits = 0 |
|
|
|
|
return currencyFormatter.format(this) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun Double.formattedHourlyDuration() : String { |
|
|
|
|
|