Reputation: 1470
In my application, there are inputs like length, weight etc. Different countries follow different measurement guidelines, like in US its miles, gallons and UK is km, litres. So does android Locale support such conversions on locale changes or do we have to code it explicitly.
Upvotes: 2
Views: 2123
Reputation: 61
you could do something like this :
if (locale.getCountry().equals("US")){
// Code to compute weight based on USA format
}
else {
// Code to compute weight based on metric system
}
Other than US , Burma and Liberia have non-metric format
Upvotes: 2
Reputation: 63293
My wouldn't that be a useful feature! No I'm afraid all you can count on Locale
for will be to assist you in formatting decimal numbers with the appropriate grouping characters. You will have to write the code to do the numeric conversions of your data and perhaps use the default Locale
on the device to determine which units to display to the user.
Upvotes: 0