Reputation: 1552
I write files and read them back. I use a comma delimited file format so that Excel can read the files easily. This works fine for me but my Dutch friend can't get the program to work. The problem is that when I write out 52.345 what ends up in the file is 52,345 and when I read it back I get 52 and then 345 as the next field.
This is not a matter of formatting numbers as this behavior happens from many sources, from edit text that the user enters, from character sequences converted to strings, as well as from numbers being written with format commands. There are hundreds of instances in the code so I need something universal that covers all default behavior and forces it to Locale.US
What I need is a way to program the app so it makes the tablet to just act like a Locale.US tablet in every way, keyboard, number writing, etc. I am not looking for a way to change one line of code.
Upvotes: 0
Views: 537
Reputation:
You can use String.format (String format, Object... args)
with not mandatory Locale argument, specified explicitely to Locale.US
:
Assuming plong is double or float and not long, cause no need decimal point for long.
waypointArray[0][2] = String.format(Locale.US, "%f", pLong);
Or, if you need this for all the application, this in onCreate of the activity, or in a class extending application :
Locale.setDefault(Locale.US);
Configuration config = new Configuration();
config.locale = Locale.US;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
Upvotes: 2