Community articlesetCurrentThreadStringValue method
Added by IBM contributorIBM on July 26, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Description

This method has a dual purpose. It can set the language that the API uses when reporting errors, and it can set the time zone that the API uses in all of its date and time operations.
The method takes two string parameters. The first parameter is a key and the second is a value. The key "Locale" sets the language, and the key "TimeZoneId" sets the time zone. The supported languages are listed in Table 1. The supported time zones are the time zones in the International Components for Unicode (ICU)external link library, which correspond to Olson time zone data.

Method

   public void setCurrentThreadStringValue(
      String key,
      String value
   ) throws UWIException;


Parameters

Table 1. set current thread string value parameters
ExpressionTypeDescription
key StringMust be "Locale" to set the language that the API uses for error reporting, or "TimeZoneId" to set the time zone that the API uses in all of its date and time operations.
valueStringWhen setting the language, use any one of the Locale Names that correspond to the language that you want. The valid Locale Names are listed in Table 1.
When setting the time zone, use a valid time zone ID from the ICU library or from the Olson time zone database. The ID is of the form continent/city or ocean/city. For example, the ID "America/Los_Angeles" will set the time zone to the west coast of USA.


Returns

Returns nothing. Throws a UWIException if an error occurs. If you pass in a non valid Locale Name, the method will not throw an exception. An exception is thrown only if the method fails to set a value.

Notes

The API can report errors in the following languages:
Table 2. API supported languages
LanguageLocaleLocale Name
ArabicAlgeriaar_DZ

Bahrain ar_BH

Egyptar_EG

Iraqar_IQ

Jordanar_JO

Kuwaitar_KW

Lebanonar_LB

Libyaar_LY

Moroccoar_MA

Omanar_OM

Qatarar_QA

Saudi Arabiaar_SA

Sudanar_SD

Syriaar_SY

Tunisiaar_TN

United Arab Emiratesar_AE

Yemenar_YE
ChineseSimplified Han, Chinazh_Hans_CN

Simplified Han, Singaporezh_Hans_SG

Traditional Han, Hong Kong S.A.R., Chinazh_Hant_HK

Traditional Han, Taiwanzh_Hant_TW
CroatianCroatiahr_HT
CzechCzech Republiccs_CZ
DanishDenmarkda_DK
DutchBelgiumnl_BE

The Netherlandsnl_NL
EnglishAustraliaen_AU

Belgiumen_BE

Canadaen_CA

Hong Kong S.A.R., Chinaen_HK

Indiaen_IN

Irelanden_IE

New Zealanden_NZ

Philippinesen_PH

Singaporeen_SG

South Africaen_ZA

United Kingdomen_GB

United Statesen_US
FinnishFinlandfi_FI
FrenchBelgiumfr_BE

Canadafr_CA

Francefr_FR

Luxembourgfr_LU

Switzerlandfr_CH
GermanAustriade_AT

Germanyde_DE

Luxembourgde_LU

Switzerlandde_CH
GreekGreeceel_GR
HebrewIsraelhe_IL
HungarianHungaryhu_HU
ItalianItalyit_IT

Switzerlandit_CH
JapaneseJapanja_JP
KoreanSouth Koreako_KR
Norwegian BokmålNorwaynb_NO
PolishPolandpl_PL
PortugueseBrazilpt_BR

Portugalpt_PT
RomanianRomaniaro_RO
RussianRussianru_RU
SlovakSlovakiask_SK
SloveneSloveniasl_SI
SpanishArgentinaes_AR

Boliviaes_BO

Chilees_CL

Colombiaes_CO

Costa Ricaes_CR

Dominican Republices_DO

Ecuadores_EC

El Salvadores_SV

Guatemalaes_GT

Hondurases_HN

Mexicoes_MX

Nicaraguaes_NI

Panamaes_PA

Paraguayes_PY

Perues_PE

Puerto Ricoes_PR

Spaines_ES

United Stateses_US

Uruguayes_UY

Venezuelaes_VE
SwedishSwedensv_SE
TurkishTurkeytr_TR


Example

When called with the string "Paris", the sample method sets the language to French and the time zone to Europe/Paris.
public void setCurrentLocation(String location)
{
  LocalizationManager theManager;
 
  if (location.equalsIgnoreCase("paris"))
  {
    try
    {
     theManager.setCurrentThreadStringValue("Locale", "fr_FR");
     theManager.setCurrentThreadStringValue("TimeZoneId", "Europe/Paris");
    }
    catch (UWIException e)
    {
      System.out.println(e.Message());
    }
  }
}