List of usage examples for java.util Locale Locale
public Locale(String language, String country)
From source file:com.bibisco.manager.LocaleManager.java
private Locale initLocale() { Locale lLocale = null;/*from w w w . j av a 2 s.co m*/ mLog.debug("Start initLocale()"); PropertiesManager lPropertiesManager = PropertiesManager.getInstance(); String lStrLocale = lPropertiesManager.getProperty("locale"); if (StringUtils.isNotBlank(lStrLocale)) { String[] lStrLocaleSplit = lStrLocale.split("_"); lLocale = new Locale(lStrLocaleSplit[0], lStrLocaleSplit[1]); } else { lLocale = Locale.getDefault(); lPropertiesManager.updateProperty("locale", lLocale.toString()); } mLog.debug("End initLocale()"); return lLocale; }
From source file:com.terradue.jcatalogue.client.internal.converters.LocaleConverter.java
public Object convert(@SuppressWarnings("rawtypes") Class type, Object value) { if (value == null) { throw new ConversionException("Null values not supported in this version."); }//from ww w . jav a 2 s. c o m if (String.class == type) { if (value instanceof Locale) { Locale locale = (Locale) value; return locale.getLanguage() + SEPARATOR + locale.getCountry(); } } else if (Locale.class == type) { if (value instanceof String) { StringTokenizer tokenizer = new StringTokenizer((String) value, SEPARATOR); return new Locale(tokenizer.nextToken(), tokenizer.nextToken()); } } throw new ConversionException(format("type %s and value %s not supported", type, value)); }
From source file:com.gammalabs.wifianalyzer.wifi.band.Country.java
Locale getCountry(@NonNull String countryCode) { String code = StringUtils.capitalize(countryCode); Locale country = countries.get(code); if (country == null) { country = new Locale("", code); }//from w ww. jav a2s . c o m return country; }
From source file:com.salesmanager.core.util.LocaleUtil.java
public static Locale getDefaultLocale() { Configuration conf = PropertiesUtil.getConfiguration(); int defaultCountryId = conf.getInt("core.system.defaultcountryid", 38); Map countriesMap = RefCache.getAllcountriesmap(Constants.ENGLISH); if (countriesMap == null) { log.error("Cannot get object from database, check your database configuration"); }//from w w w.j a v a 2 s .com Country country = (Country) countriesMap.get(defaultCountryId); Locale locale = new Locale(conf.getString("core.system.defaultlanguage", Constants.ENGLISH_CODE), country.getCountryIsoCode2()); return locale; }
From source file:de.awtools.lang.TranslatorTest.java
@Test public void testDefaultLocale() { Locale germany = new Locale("de", "DE"); assertThat(germany).isEqualTo(Locale.GERMANY); Locale german = new Locale("de"); assertThat(german).isEqualTo(Locale.GERMAN); }
From source file:com.cyclopsgroup.waterview.ui.action.ChangeLocale.java
/** * Overwrite or implement method execute() * * @see com.cyclopsgroup.waterview.Action#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.ActionContext) */// www . j ava2 s . com public void execute(RuntimeData data, ActionContext context) throws Exception { String localeName = data.getParameters().getString("locale_name"); if (StringUtils.isEmpty(localeName)) { data.getSessionContext().remove(RuntimeData.LOCALE_NAME); } else { String[] countryLanguage = StringUtils.split(localeName, '|'); Locale locale = new Locale(countryLanguage[1], countryLanguage[0]); data.getSessionContext().put(RuntimeData.LOCALE_NAME, locale); } }
From source file:de.cosmocode.commons.converter.LocaleCountryIsoConverter.java
@Override public String toAlpha3(String iso3166Alpha2) { Preconditions.checkNotNull(iso3166Alpha2, "iso3166Alpha2 must not be null"); if (Patterns.ISO_3166_1_ALPHA_2.matcher(iso3166Alpha2).matches()) { try {//from w w w . j a v a 2 s . co m return new Locale("", iso3166Alpha2).getISO3Country(); } catch (MissingResourceException e) { throw new IsoConversionException("No known alpha-3 code for " + iso3166Alpha2, e); } } else if (Patterns.ISO_3166_1_ALPHA_3.matcher(iso3166Alpha2).matches()) { // already ISO 639-2 (three letter) return iso3166Alpha2; } else if (StringUtils.isBlank(iso3166Alpha2)) { // this is here for convenience, to allow empty languages return TrimMode.EMPTY.apply(iso3166Alpha2); } else { throw new IllegalArgumentException("given country code " + iso3166Alpha2 + " not in ISO 3166 alpha-2"); } }
From source file:countries.ListCountry.java
public void getListOfCountries() { int supportedLocale = 0, nonSupportedLocale = 0; for (String countryCode : getISOCountries()) { Locale locale = null;//from w w w.j a va 2 s . c o m if (!languagesOfCountries.containsKey(countryCode)) { locale = new Locale("", countryCode); nonSupportedLocale++; } else { // create a Locale with own country's languages locale = new Locale(languagesOfCountries.get(countryCode), countryCode); supportedLocale++; } out.printf("Country Code: %1$2s, Name: %2$-45s %3$-45s %4$-45s Languages: %5$10s\n", locale.getCountry(), locale.getDisplayCountry(ENGLISH), parens(locale.getDisplayCountry(FRENCH)), parens(locale.getDisplayCountry(locale)), locale.getDisplayLanguage()); } out.println("nonSupportedLocale: " + nonSupportedLocale); out.println("supportedLocale: " + supportedLocale); }
From source file:quanlyhocvu.api.mongodb.service.HandleExcelFile.java
public void write(List<HocSinhDTO> listHocSinh) throws IOException, WriteException { File file = new File(inputFile); WorkbookSettings wbSettings = new WorkbookSettings(); wbSettings.setLocale(new Locale("en", "EN")); WritableWorkbook workbook = Workbook.createWorkbook(file, wbSettings); workbook.createSheet("DanhSachHocSinh", 0); WritableSheet excelSheet = workbook.getSheet(0); createLabel(excelSheet);/* w w w. ja v a 2 s .c o m*/ createContent(excelSheet, listHocSinh); workbook.write(); workbook.close(); }
From source file:dataform.components.WorkTimer.java
private void timer_ActionPerformed(ActionEvent evt) { stopWatch.split();/*from w w w. j a v a 2 s . c o m*/ setText(DateFormatUtils.formatUTC(stopWatch.getTime(), "HH:mm:ss", new Locale("EN", "GB"))); stopWatch.unsplit(); }