Is it possible in Java without any extra library to internationalize distances?
I mean it is possible to handle that with date, time, currencies, numbers...
I would have expected to find a NumberFormat.getDistanceInstance or something.
Is there something like that already embedded or should i make my own internationalization system for distances (mostly miles vs kilometers)
Internalization or I18N refers to the capability of an Application to be able to serve users in multiple and different languages. Java has in-built support for Internalization. Java also provides formatting of numbers, currencies and adjustment of date and time accordingly.
setDefault(Locale) method. The setDefault(Locale aLocale) method lets your application set a systemwide (actually VM-wide) resource. After you set the default locale with this method, subsequent calls to Locale. getDefault() will return the newly set locale.
Commonly used methods of Locale classpublic String getDisplayLanguage() it returns the language name of this locale object. public String getDisplayVariant() it returns the variant code for this locale object. public String getISO3Country() it returns the three letter abbreviation for the current locale's country.
I would love to hear about such formatter but unfortunately I never did. The problem is, there is no such data in CLDR yet, so it is not to easy to do.
That is to say that people actually think about this for quite a while – see ICU's Measure class. Unfortunately for now, it seems as close you can get is to determine measurement system – see LocaleData and LocaleData.MeasurementSystem.
After that you are on your own. You would need to leave this for translators (they need to actually translate units as well as formatting pattern).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With