Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the user preferred units? (metric (meters) or imperial (miles))?

I would like to know what are the user-preferred units between miles and meters. It seems that the "Locale" class doesn't allow that.

like image 463
Regis_AG Avatar asked Aug 11 '11 12:08

Regis_AG


1 Answers

Although there isn't a way to get the preferred units using Locale, you can assume by default that if the Locale indicates the United States or Myanmar (locale.getISO3Country().equalsIgnoreCase("usa") || locale.getISO3Country().equalsIgnoreCase("mmr")) the preferred units are imperial, otherwise the preferred units are metric. In any case where units may be shown in either imperial or metric form, the measurement system shown should be a user-settable preference.

There are certain idiosyncrasies involving units in some countries. (See also the accepted answer at the time of this writing.) For example, although the preferred everyday units in the United Kingdom are metric units, there are some exceptions, notably—

  • miles and miles per hour, in ground transportation;
  • miles per hour, in wind speeds;
  • pints and gallons, for milk and beer (but not most other foods and beverages); and
  • stone, or stone and pounds, for a person's weight.
like image 176
Peter O. Avatar answered Sep 21 '22 13:09

Peter O.