List of usage examples for java.util Locale Locale
public Locale(String language)
From source file:com.tdclighthouse.prototype.utils.TdcUtils.java
public static String dateToRFC1123(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, new Locale("en")); dateFormat.setTimeZone(TimeZone.getTimeZone(GMT)); String result = dateFormat.format(date); return result; }
From source file:Main.java
/** * @return the old style locale string constructed from * {@link Settings.Secure#TTS_DEFAULT_LANG}, * {@link Settings.Secure#TTS_DEFAULT_COUNTRY} and * {@link Settings.Secure#TTS_DEFAULT_VARIANT}. If no such locale is * set, then return the default phone locale. *//*from w ww . j a v a 2 s. c o m*/ @SuppressWarnings({ "deprecation", "javadoc" }) private static Locale getV1Locale(ContentResolver resolver) { final String language = Settings.Secure.getString(resolver, Settings.Secure.TTS_DEFAULT_LANG); if (TextUtils.isEmpty(language)) { return Locale.getDefault(); } final String country = Settings.Secure.getString(resolver, Settings.Secure.TTS_DEFAULT_COUNTRY); final String variant = Settings.Secure.getString(resolver, Settings.Secure.TTS_DEFAULT_VARIANT); final String locale = constructLocaleString(language, country, variant); return new Locale(locale); }
From source file:com.mycompany.CRMFly.AdditionalFeatures.LocaleBean.java
public void setLanguage(String language) { this.locale = new Locale(language); }
From source file:org.obiba.mica.web.model.CountryDtos.java
Mica.CountryDto asDto(String countryIso) { Mica.CountryDto.Builder builder = Mica.CountryDto.newBuilder().setIso(countryIso); micaConfigService.getConfig().getLocales() .forEach(locale -> builder.addName(Mica.LocalizedStringDto.newBuilder() .setLang(locale.getLanguage()).setValue(new Locale(countryIso).getDisplayCountry(locale)))); return builder.build(); }
From source file:io.bibleget.BibleGetI18N.java
/** * * @return/* www .j a va2 s . com*/ */ public static ResourceBundle getMessages() { lcl = BibleGetIO.getLocale(); Locale myLocale; myLocale = new Locale(lcl); try { myResource = ResourceBundle.getBundle("io.bibleget.resources.messages", myLocale); } catch (MissingResourceException ex) { myResource = ResourceBundle.getBundle("io.bibleget.resources.messages"); } return myResource; }
From source file:com.fredhopper.connector.index.TestLocale.java
@Test public void test() { final String lang = "de_DE"; final Locale loc = new Locale(lang); System.out.println(loc.GERMANY); System.out.println(loc);//from w w w . ja v a2 s . c o m final Locale loc2 = LocaleUtils.toLocale(lang); System.out.println(loc2); }
From source file:Main.java
/** * Parses the contents of {@link Engine#EXTRA_AVAILABLE_VOICES} and returns * a unmodifiable list of {@link Locale}s sorted by display name. See * {@link #LOCALE_COMPARATOR} for sorting information. * * @param availableLanguages A list of locale strings in the form * {@code language-country-variant}. * @return A sorted, unmodifiable list of {@link Locale}s. *///w w w .j av a 2 s .co m public static List<Locale> parseAvailableLanguages(List<String> availableLanguages) { final List<Locale> results = new ArrayList<Locale>(availableLanguages.size()); for (String availableLang : availableLanguages) { final String[] langCountryVar = availableLang.split("-"); final Locale loc; if (langCountryVar.length == 1) { loc = new Locale(langCountryVar[0]); } else if (langCountryVar.length == 2) { loc = new Locale(langCountryVar[0], langCountryVar[1]); } else if (langCountryVar.length == 3) { loc = new Locale(langCountryVar[0], langCountryVar[1], langCountryVar[2]); } else { continue; } results.add(loc); } // Sort by display name, ascending case-insensitive. Collections.sort(results, LOCALE_COMPARATOR); return Collections.unmodifiableList(results); }
From source file:com.inkubator.hrm.web.converter.CompanyConverter.java
@Override public String getAsString(FacesContext context, UIComponent component, Object value) { ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages", new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString())); String message = StringUtils.EMPTY; String data = (String) value; if (Objects.equals(data, HRMConstant.ORGANIZATION_LEVEL_HOLDING)) { message = resourceBundle.getString("organization.holding"); } else if (Objects.equals(data, HRMConstant.ORGANIZATION_LEVEL_COMPANY)) { message = resourceBundle.getString("organization.company"); }/*from w ww .j a v a 2 s. c o m*/ return message; }
From source file:net.pms.Messages.java
public static String getString(String key, String lang) { if (StringUtils.isEmpty(lang)) { return getString(key); }//from ww w . j a va 2 s . c o m Locale l = new Locale(lang); ResourceBundle rb = ResourceBundle.getBundle(BUNDLE_NAME, l); if (rb == null) { rb = RESOURCE_BUNDLE; } return getString(key, rb); }
From source file:com.inkubator.hrm.web.converter.BatchJobConverter.java
@Override public String getAsString(FacesContext context, UIComponent component, Object value) { ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages", new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString())); String message = StringUtils.EMPTY; String data = (String) value; switch (data) { case "jobSynchDataFingerRealization": message = resourceBundle.getString("batch.jobSynchDataFingerRealization"); break;//from w ww .j a v a 2 s . c o m case "jobPaySalaryUpload": message = resourceBundle.getString("batch.jobPaySalaryUpload"); break; case "jobPayAttendanceUpload": message = resourceBundle.getString("batch.jobPayAttendanceUpload"); break; case "jobPayTempOvertimeUpload": message = resourceBundle.getString("batch.jobPayTempOvertimeUpload"); break; case "jobPayEmployeeCalculation": message = resourceBundle.getString("batch.jobPayEmployeeCalculation"); break; case "jobPayReceiverAccount": message = resourceBundle.getString("batch.jobPayReceiverAccount"); break; case "jobMonthEndPayroll": message = resourceBundle.getString("batch.jobMonthEndPayroll"); break; case "jobLoanUpload": message = resourceBundle.getString("batch.jobLoanUpload"); break; case "jobUnregCalculation": message = resourceBundle.getString("batch.jobUnregCalculation"); break; case "jobUnregPayroll": message = resourceBundle.getString("batch.jobUnregPayroll"); break; case "jobAnnouncementLog": message = resourceBundle.getString("batch.jobAnnouncementLog"); break; case "jobEmailingAnnouncementNotSent": message = resourceBundle.getString("batch.jobEmailingAnnouncementNotSent"); break; default: message = data; break; } return message; }