I use kotlin's decimal format and when my input is 15.4, my phone shows 15.4 instead of 15.4. But in the virtual machine on the computer, it still displays 15.4 correctly. I think this is a locale problem, can anyone help me?
Here is my code: val formatter = DecimalFormat("##0.######") return formatter.format(value)
I need the following result: 15.4 ->> 15.4 But I got the result: 15.4 ->> 15,4
Seems like you should use DecimalFormatSymbols to format with the period.
fun main() {
val symbols = DecimalFormatSymbols(Locale.US)
val formatter = DecimalFormat("##0.######", symbols)
println(formatter.format(15.4)) // should be 15.4
}