public class LocaleTools
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
LocaleTools.LocaleHelper
UI helper class implementing utility methods on the locale object.
|
Modifier and Type | Field and Description |
---|---|
static int |
ASCII_INTEGER_NO_BREAK_SPACE |
static int |
ASCII_INTEGER_SPACE |
static java.lang.String |
CLASS_VERSION |
static java.lang.String |
LOCALE_TOOLS_PATH |
Constructor and Description |
---|
LocaleTools()
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
LocaleTools.LocaleHelper[] |
getAvailableLocaleHelpers()
Returns an array of LocaleHelper for all available locales.
|
java.lang.String |
getDateStyle()
Returns the locale date pattern style.
|
java.lang.String |
getDateTimeStyle()
Returns the locale dateTime pattern style.
|
static LocaleTools |
getInstance()
Resolves LocaleTools component instance by path, if there is DynamoHttpServletRequest object associated with the current thread.
|
static java.util.Locale |
getLocale(java.lang.String pLocale)
The pLocale argument represents the entire locale,
with the language, country and variant separated by underbars.
|
java.lang.String |
getProfileLocalePropertyName()
Returns the property on the user profile that holds the user preferred locale
for representing dates.
|
java.lang.String |
getRemoveSpacesRegex()
Returns the regular expression
|
java.lang.String |
getTimeStyle()
Returns the locale time pattern style.
|
boolean |
getUseNumberGrouping()
Returns true if grouping is being used with number formatting.
|
LocaleTools.LocaleHelper |
getUserFormattingLocaleHelper()
Returns a LocaleHelper for the user preferred locale to be used when displaying formatted dates.
|
LocaleTools.LocaleHelper |
getUserLocaleHelper()
Returns the LocaleHelper to use when looking up localized messages for display to the user.
|
java.lang.String |
localizeNumberString(java.lang.String pValue)
Parses a string value and returns a localized string representation.
|
java.lang.String |
localizeNumberString(java.lang.String pValue,
java.util.Locale pLocale)
Parses a string value and returns a localized string representation.
|
java.lang.String |
localizeNumberString(java.lang.String pValue,
java.text.NumberFormat pNumberFormat)
Parses a string value and returns a localized string representation.
|
java.lang.String |
localizeNumberString(java.lang.String pValue,
java.lang.String pFormatString)
Parses a string value and returns a localized string representation.
|
java.lang.String |
localizeNumberString(java.lang.String pValue,
java.lang.String pFormatString,
java.util.Locale pLocale)
Parses a string value and returns a localized string representation.
|
java.lang.String |
localizeNumberString(java.lang.String pValue,
java.lang.String pFormatString,
java.util.Locale pLocale,
java.text.NumberFormat pNumberFormat)
Parses a string value and returns a localized string representation.
|
java.lang.String |
parseLocalizedString(java.lang.String pLocalizedNumber)
Converts the value entered by the user to a non-localized number
This method calls removeSpaces to remove spaces used as grouping separators
in some locales.
|
java.lang.String |
removeSpaces(java.lang.String pValue)
This method will be used to remove spaces from a supplied string.
|
void |
setDateStyle(java.lang.String pStyle)
Defines the locale date pattern style to use for subsequent calls to LocaleHelper.getDatePattern().
|
void |
setDateTimeStyle(java.lang.String pStyle)
Defines the locale dateTime pattern style to use for subsequent calls to LocaleHelper.getDateTimePattern().
|
void |
setProfileLocalePropertyName(java.lang.String pProfileLocalePropertyName)
Sets the property on the user profile that holds the user preferred locale
for representing dates.
|
void |
setRemoveSpacesRegex(java.lang.String pRemoveSpacesRegex)
Defines the regular expression used within the remove spaces method
|
void |
setTimeStyle(java.lang.String pStyle)
Defines the locale time pattern style to use for subsequent calls to LocaleHelper.getTimePattern().
|
void |
setUseNumberGrouping(boolean pUseNumberGrouping)
Set whether grouping is being used with number formatting.
|
public static java.lang.String CLASS_VERSION
public static final java.lang.String LOCALE_TOOLS_PATH
public static final int ASCII_INTEGER_SPACE
public static final int ASCII_INTEGER_NO_BREAK_SPACE
public LocaleTools()
SimpleDateFormat
public static LocaleTools getInstance()
public void setProfileLocalePropertyName(java.lang.String pProfileLocalePropertyName)
pProfileLocalePropertyName
- The property on the user profile that holds
the user preferred locale for representing dates.public java.lang.String getProfileLocalePropertyName()
public void setRemoveSpacesRegex(java.lang.String pRemoveSpacesRegex)
pRemoveSpacesRegex
- The regular expressionpublic java.lang.String getRemoveSpacesRegex()
public void setDateStyle(java.lang.String pStyle)
<dsp:importbean bean="/atg/core/i18n/LocaleTools"/>
<dsp:setvalue bean="LocaleTools.dateStyle" value="short"/>
<fmt:formatDate value="${date}" pattern="${LocaleTools.userPreferredLocale.datePattern}"/>
pStyle
- The locale date pattern style.public java.lang.String getDateStyle()
public void setDateTimeStyle(java.lang.String pStyle)
<dsp:importbean bean="/atg/core/i18n/LocaleTools"/>
<dsp:setvalue bean="LocaleTools.dateTimeStyle" value="short"/>
<fmt:formatDate value="${dateTime}" pattern="${LocaleTools.userPreferredLocale.dateTimePattern}"/>
pStyle
- The locale dateTime pattern style.public java.lang.String getDateTimeStyle()
public void setTimeStyle(java.lang.String pStyle)
<dsp:importbean bean="/atg/core/i18n/LocaleTools"/>
<dsp:setvalue bean="LocaleTools.timeStyle" value="short"/>
<fmt:formatDate value="${time}" pattern="${LocaleTools.userPreferredLocale.timePattern}"/>
pStyle
- The locale time pattern style.public java.lang.String getTimeStyle()
public void setUseNumberGrouping(boolean pUseNumberGrouping)
pUseNumberGrouping
- booleanpublic boolean getUseNumberGrouping()
public java.lang.String localizeNumberString(java.lang.String pValue) throws java.lang.NumberFormatException
pValue
- value to be parsedjava.lang.NumberFormatException
- if pValue could not be parsedpublic java.lang.String localizeNumberString(java.lang.String pValue, java.util.Locale pLocale)
pValue
- value to be parsedpLocale
- the locale to parse the value tojava.lang.NumberFormatException
- if pValue could not be parsedpublic java.lang.String localizeNumberString(java.lang.String pValue, java.lang.String pFormatString)
pValue
- value to be parsedpFormatString
- the pattern to use for the decimal format symbolsjava.lang.NumberFormatException
- if pValue could not be parsedpublic java.lang.String localizeNumberString(java.lang.String pValue, java.text.NumberFormat pNumberFormat)
pValue
- value to be parsedpNumberFormat
- instance of NumberFormat to usejava.lang.NumberFormatException
- if pValue could not be parsedpublic java.lang.String localizeNumberString(java.lang.String pValue, java.lang.String pFormatString, java.util.Locale pLocale)
pValue
- value to be parsedpFormatString
- the pattern to use for the decimal format symbolspLocale
- the locale to parse the value tojava.lang.NumberFormatException
- if pValue could not be parsedpublic java.lang.String localizeNumberString(java.lang.String pValue, java.lang.String pFormatString, java.util.Locale pLocale, java.text.NumberFormat pNumberFormat)
pValue
- value to be parsedpFormatString
- the pattern to use for the decimal format symbolspLocale
- the locale to parse the value topNumberFormat
- instance of NumberFormat to usejava.lang.NumberFormatException
- if pValue could not be parsedpublic java.lang.String parseLocalizedString(java.lang.String pLocalizedNumber)
pLocalizedNumber
- string value user inputpublic java.lang.String removeSpaces(java.lang.String pValue)
pValue
- string value to updatepublic LocaleTools.LocaleHelper[] getAvailableLocaleHelpers()
DateFormat.getAvailableLocales()
public LocaleTools.LocaleHelper getUserLocaleHelper()
ServletUtil.getUserLocale()
public LocaleTools.LocaleHelper getUserFormattingLocaleHelper()
public static java.util.Locale getLocale(java.lang.String pLocale)
http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
Country cope is a valid ISO Country Code. These
codes are the upper-case, two-letter codes as defined by ISO-3166.
You can find a full list of these codes at a number of sites, such as:
http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html