Jive Messenger 2.2.2 Javadoc

org.jivesoftware.util
Class LocaleUtils

java.lang.Object
  extended by org.jivesoftware.util.LocaleUtils

public class LocaleUtils
extends Object

A set of methods for retrieving and converting locale specific strings and numbers.

Author:
Jive Software

Method Summary
static String getLocalizedNumber(double number)
           
static String getLocalizedNumber(double number, Locale locale)
           
static String getLocalizedNumber(long number)
           
static String getLocalizedNumber(long number, Locale locale)
           
static String getLocalizedString(String key)
          Returns an internationalized string loaded from a resource bundle.
static String getLocalizedString(String key, List arguments)
          Returns an internationalized string loaded from a resource bundle using the locale specified by JiveGlobals.getLocale() substituting the passed in arguments.
static String getLocalizedString(String key, Locale locale)
          Returns an internationalized string loaded from a resource bundle using the passed in Locale.
static String getLocalizedString(String key, Locale locale, List arguments)
          Returns an internationalized string loaded from a resource bundle using the passed in Locale substituting the passed in arguments.
static ResourceBundle getResourceBundle(String baseName, Locale locale)
          Returns the specified resource bundle, which is a properties file that aids in localization of skins.
static String[][] getTimeZoneList()
          Returns a list of all available time zone's as a String [][].
static Locale localeCodeToLocale(String localeCode)
          Converts a locale string like "en", "en_US" or "en_US_win" to a Java locale object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

localeCodeToLocale

public static Locale localeCodeToLocale(String localeCode)
Converts a locale string like "en", "en_US" or "en_US_win" to a Java locale object. If the conversion fails, null is returned.

Parameters:
localeCode - the locale code for a Java locale. See the Locale class for more details.

getTimeZoneList

public static String[][] getTimeZoneList()
Returns a list of all available time zone's as a String [][]. The first entry in each list item is the timeZoneID, and the second is the display name.

Normally, there are many ID's that correspond to a single display name. However, the list has been paired down so that a display name only appears once. Normally, the time zones will be returned in order: -12 GMT,..., +0GMT,... +12GMT..., etc.

Returns:
a list of time zones, as a tuple of the zime zone ID, and its display name.

getResourceBundle

public static ResourceBundle getResourceBundle(String baseName,
                                               Locale locale)
Returns the specified resource bundle, which is a properties file that aids in localization of skins. This method is handy since it uses the class loader that other Jive classes are loaded from (hence, it can load bundles that are stored in jive.jar).

Parameters:
baseName - the name of the resource bundle to load.
locale - the desired Locale.
Returns:
the specified resource bundle, if it exists.

getLocalizedString

public static String getLocalizedString(String key)
Returns an internationalized string loaded from a resource bundle. The locale used will be the locale specified by JiveGlobals.getLocale().

Parameters:
key - the key to use for retrieving the string from the appropriate resource bundle.
Returns:
the localized string.

getLocalizedString

public static String getLocalizedString(String key,
                                        Locale locale)
Returns an internationalized string loaded from a resource bundle using the passed in Locale.

Parameters:
key - the key to use for retrieving the string from the appropriate resource bundle.
locale - the locale to use for retrieving the appropriate locale-specific string.
Returns:
the localized string.

getLocalizedString

public static String getLocalizedString(String key,
                                        List arguments)
Returns an internationalized string loaded from a resource bundle using the locale specified by JiveGlobals.getLocale() substituting the passed in arguments. Substitution is handled using the MessageFormat class.

Parameters:
key - the key to use for retrieving the string from the appropriate resource bundle.
arguments - a list of objects to use which are formatted, then inserted into the pattern at the appropriate places.
Returns:
the localized string.

getLocalizedString

public static String getLocalizedString(String key,
                                        Locale locale,
                                        List arguments)
Returns an internationalized string loaded from a resource bundle using the passed in Locale substituting the passed in arguments. Substitution is handled using the MessageFormat class.

Parameters:
key - the key to use for retrieving the string from the appropriate resource bundle.
locale - the locale to use for retrieving the appropriate locale-specific string.
arguments - a list of objects to use which are formatted, then inserted into the pattern at the appropriate places.
Returns:
the localized string.

getLocalizedNumber

public static String getLocalizedNumber(long number)

getLocalizedNumber

public static String getLocalizedNumber(long number,
                                        Locale locale)

getLocalizedNumber

public static String getLocalizedNumber(double number)

getLocalizedNumber

public static String getLocalizedNumber(double number,
                                        Locale locale)

Jive Messenger 2.2.2 Javadoc

Copyright © 1999-2004 Jive Software.