Class L10NManager
The localization manager allows adapting values for display in different locales thru parsing and formatting capabilities (similar to JavaSE's DateFormat/NumberFormat). It also includes language/locale/currency related API's similar to Locale/currency API's from JavaSE.
The sample code below just lists the various capabilities of the API:
Form hi = new Form("L10N", new TableLayout(16, 2));
L10NManager l10n = L10NManager.getInstance();
hi.add("format(double)").add(l10n.format(11.11)).
add("format(int)").add(l10n.format(33)).
add("formatCurrency").add(l10n.formatCurrency(53.267)).
add("formatDateLongStyle").add(l10n.formatDateLongStyle(new Date())).
add("formatDateShortStyle").add(l10n.formatDateShortStyle(new Date())).
add("formatDateTime").add(l10n.formatDateTime(new Date())).
add("formatDateTimeMedium").add(l10n.formatDateTimeMedium(new Date())).
add("formatDateTimeShort").add(l10n.formatDateTimeShort(new Date())).
add("getCurrencySymbol").add(l10n.getCurrencySymbol()).
add("getLanguage").add(l10n.getLanguage()).
add("getLocale").add(l10n.getLocale()).
add("isRTLLocale").add("" + l10n.isRTLLocale()).
add("parseCurrency").add(l10n.formatCurrency(l10n.parseCurrency("33.77$"))).
add("parseDouble").add(l10n.format(l10n.parseDouble("34.35"))).
add("parseInt").add(l10n.format(l10n.parseInt("56"))).
add("parseLong").add("" + l10n.parseLong("4444444"));
hi.show();
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedL10NManager(String language, String locale) Instances of this class should be received via the Display class -
Method Summary
Modifier and TypeMethodDescriptionformat(double number) Format a double number for this localeformat(double number, int decimalPlaces) Formats a number as a String with a fixed number of decimal placesformat(int number) Format an integer number for this localeformatCurrency(double currency) Format a currency valueFormats a date in a long form e.g.Formats a date in a short form e.g.Formats a date and a time in a default form e.g.Formats a date and a time in a default form e.g.Formats a date and a time in a default form e.g.formatTime(Date d) Formats the time in a default form e.g.Returns the currency symbol for this localestatic L10NManagerConvenience method that invokes Display.getLocalizationManager()Returns the current locale language as an ISO 639 two letter codeDetermines the locale (location) as an ISO 3166 country codegetLongMonthName(Date date) Gets the long month name in the current locale for the given date.getShortMonthName(Date date) Gets the short month name in the current locale for the given date.booleanIndicates whether the language is a right to left languagedoubleparseCurrency(String amount) Parses the currency valuedoubleparseDouble(String localeFormattedDecimal) Parses a double based on locale conventionsintParses an integer based on locale conventionslongParses a long based on locale conventionsvoidForces the locale/language
-
Constructor Details
-
L10NManager
-
-
Method Details
-
getInstance
Convenience method that invokes Display.getLocalizationManager()
Returns
the L10NManager instance
-
getLanguage
Returns the current locale language as an ISO 639 two letter code
Returns
iso language string
-
setLocale
-
format
Format an integer number for this locale
Parameters
number: the number to format
Returns
a string representation of a number
-
format
Format a double number for this locale
Parameters
number: the number to format
Returns
a string representation of a number
-
getShortMonthName
-
getLongMonthName
-
formatCurrency
Format a currency value
Parameters
currency: the monetary value
Returns
a string representation of a number
-
getCurrencySymbol
Returns the currency symbol for this locale
Returns
currency symbol
-
formatDateLongStyle
-
formatDateShortStyle
-
formatDateTime
-
formatDateTimeMedium
-
formatTime
-
formatDateTimeShort
-
isRTLLocale
public boolean isRTLLocale()Indicates whether the language is a right to left language
Returns
true for bidi/rtl languages
-
getLocale
Determines the locale (location) as an ISO 3166 country code
Returns
the locale
-
format
Formats a number as a String with a fixed number of decimal places
Parameters
-
number: the number -
decimalPlaces: decimals
Returns
formatted string
-
-
parseDouble
Parses a double based on locale conventions
Parameters
localeFormattedDecimal: the locale formatted number
Returns
the parsed double
-
parseLong
Parses a long based on locale conventions
Parameters
localeFormattedLong: the number
Returns
a long
-
parseInt
Parses an integer based on locale conventions
Parameters
localeFormattedInteger: the number
Returns
a parsed number
-
parseCurrency
Parses the currency value
Parameters
amount: the amount
Returns
a numeric value for the currency
-