I want to display some coördinates in my Android app.
I receive two double values (lat and long in decimal degrees notation) from my backend.
Example data:
var lat : Double = 52.5027
var long : Double = 5.41982
Now i fill my textView in my class file:
tvLat.text = getString(R.string.gps_format, lat)
tvLong.text = getString(R.string.gps_format, lat)
and my xml resource file contains this:
<string name="gps_format">%,.5f°</string>
It displays:
52,50270°
5,41982°
As I live in the Netherlands it is formatted accordingly.
See https://developer.android.com/reference/java/util/Formatter
Number Localization Algorithm
- ...
- If a decimal separator is present, a locale-specific decimal separator is substituted.
We typically use a , as a decimal separator, and . as a group separator in the Netherlands.
Question:
- Is there an international standard for the notation of coördinates in decimal degrees which requires the decimal seperator to be
.? - If there is, or I just want to, how do I achieve this without changing my locale or formatting for the entire app?
Desired output:
52.50270°
5.41982°
I have not found a way yet for the XML, so my guess is that it will have to be done with code. I've looked into the setDecimalSeparator method, but I can't get any working solution.