Class LocaleUtils


  • public class LocaleUtils
    extends Object
    A helper class for Locale functionality and locale specific functionality. This includes message retrieval and formatting from message bundles.
    Version:
    $Revision: $
    Author:
    jagander
    • Method Detail

      • setLocale

        protected void setLocale​(Locale locale)
      • getLocale

        public Locale getLocale()
      • setDevMode

        protected void setDevMode​(Boolean devMode)
      • isDevMode

        public boolean isDevMode()
      • setBundleName

        protected void setBundleName​(String bundleName)
      • isValidLocale

        public static boolean isValidLocale​(Locale locale)
      • stringToLocale

        public static Locale stringToLocale​(String localeName)
      • localeToString

        public static String localeToString​(Locale locale)
      • getText

        public String getText​(String key,
                              Object... arguments)
        This retrieves a message from the appropriate properties file for your given Locale. It also uses any provided arguments to make substitutions and formatting changes to the found message. Note that this uses the OGNL expression language syntax for formatting.
        Parameters:
        key - - properties key used to look up message
        arguments - - an array of arguments to be used in the message, uses OGNL syntax
        Returns:
        found and formatted message
        Throws:
        KeyNotFoundException
      • formatBytes

        public String formatBytes​(double memory)
      • formatBytes

        public String formatBytes​(double memory,
                                  Locale override)
        Format bytes to human readable text
        Parameters:
        memory - The memory value to format.
        override - The locale to be used (determines decimal and grouping separators).
        Returns:
        The formatted number string.