https://kotlinlang.org logo
#android
Title
# android
n

nickk

05/06/2019, 2:27 PM
It turns out that
Double.toString()
uses some default (?) locale , while
String.format("%.1f")
uses the locale selected by the user. So, I end up with two different decimal separators in the same message (both ‘,’ and ‘.’) Is this expected behavior?
m

Marc Knaup

05/06/2019, 4:58 PM
toString()
returns a machine-readable string which can be parsed again using
toDouble()
formatting is more for human-readable strings (but I guess can also be used for machine-readable output by using the right locale)
👍 1
n

nickk

05/07/2019, 7:31 AM
So,
toString()
uses the
en-US
locale in all cases, apparently. (though a quick google search does not result into links to official docs)
m

Marc Knaup

05/07/2019, 8:57 AM
3 Views