List of usage examples for java.util Locale getDisplayCountry
public final String getDisplayCountry()
From source file:net.rrm.ehour.ui.admin.config.MainConfigBackingBean.java
public static List<Locale> getAvailableCurrencies() { List<Locale> locales = getAvailableLocales(); SortedSet<Locale> currencyLocales = new TreeSet<>(new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { Currency curr1 = Currency.getInstance(o1); Currency curr2 = Currency.getInstance(o2); return (o1.getDisplayCountry() + ": " + curr1.getSymbol(o1)) .compareTo(o2.getDisplayCountry() + ": " + curr2.getSymbol(o2)); }// w w w.j av a2 s .c o m }); for (Locale locale : locales) { if (!StringUtils.isBlank(locale.getCountry())) { currencyLocales.add(locale); } } return new ArrayList<>(currencyLocales); }
From source file:im.neon.util.PhoneNumberUtils.java
/** * Build the country codes list/*from w w w.j av a 2s . c o m*/ */ private static void buildCountryCodesList() { if (null == mCountryCodes) { // retrieve the ISO country code String[] isoCountryCodes = Locale.getISOCountries(); List<Pair<String, String>> countryCodes = new ArrayList<>(); // retrieve the human display name for (String countryCode : isoCountryCodes) { Locale locale = new Locale("", countryCode); countryCodes.add(new Pair<>(countryCode, locale.getDisplayCountry())); } // sort by human display names Collections.sort(countryCodes, new Comparator<Pair<String, String>>() { @Override public int compare(Pair<String, String> lhs, Pair<String, String> rhs) { return lhs.second.compareTo(rhs.second); } }); mCountryNameByCC = new HashMap<>(isoCountryCodes.length); mCountryCodes = new String[isoCountryCodes.length]; mCountryNames = new String[isoCountryCodes.length]; for (int index = 0; index < isoCountryCodes.length; index++) { Pair<String, String> pair = countryCodes.get(index); mCountryCodes[index] = pair.first; mCountryNames[index] = pair.second; mCountryNameByCC.put(pair.first, pair.second); } } }
From source file:countries.ListCountry.java
/** Create Map with country code and languages. */ public void initLanguageMap() { for (Locale locale : getAvailableLocales()) { if (!isBlank(locale.getDisplayCountry())) { languagesOfCountries.put(locale.getCountry(), locale.getLanguage()); }/*from w w w . j a va 2s . c o m*/ } }
From source file:ca.travelagency.components.fields.TravelDocumentField.java
@Override protected Iterator<String> getChoices(String input) { if (StringUtils.isEmpty(input)) { return Collections.<String>emptyList().iterator(); }/*from w ww . j av a 2s . c o m*/ SortedSet<String> choices = new TreeSet<String>(); Locale[] locales = Locale.getAvailableLocales(); for (Locale locale : locales) { String country = locale.getDisplayCountry().toUpperCase(); if (country.startsWith(input.toUpperCase())) { String value = getLocalizer().getString(country, this, country); if (StringUtils.isBlank(value)) { value = country; } choices.add(WordUtils.capitalize(StringUtils.lowerCase(value + " " + suffix))); if (choices.size() == DISPLAY_MAX_SIZE) { break; } } } return choices.iterator(); }
From source file:com.graph.pie.PieGraphData.java
public PieGraphData(String startDate, String endDate) { java.sql.Connection con = null; java.sql.PreparedStatement stmt = null; java.sql.ResultSet rs = null; try {/*from w ww .j a v a 2 s .c o m*/ con = ControlPanelPool.getInstance().getConnection(); stmt = con.prepareStatement( "SELECT DISTINCT TOP 15 LeadOrganization.Country, COUNT(LeadOrganization.Country) as c FROM LeadOrganization, LeadRemoteAddress, leadSession WHERE leadSession.remoteAddress = LeadRemoteAddress.ip AND LeadRemoteAddress.LeadOrganization_uid = LeadOrganization.Id AND LeadRemoteAddress.prefered = 1 AND LeadOrganization.Country != '' AND leadSession.timeIn > CONVERT(date, ?) AND leadSession.timeIn < CONVERT(date, ?) GROUP BY LeadOrganization.Country HAVING COUNT(LeadOrganization.Country) > 0 ORDER BY c DESC"); stmt.setString(1, startDate); stmt.setString(2, endDate); rs = stmt.executeQuery(); languages = new HashMap<>(); while (rs.next()) { /* if (rs.getString("userAgent") != null) { String lang = new UserAgentDetector().parseUserAgent(rs.getString("userAgent")).getLocale().country.getLabel(); if (languages.containsKey(lang)) { languages.put(lang, languages.get(lang) + 1); } else { languages.put(lang, 1); } } */ Locale l = new Locale("", rs.getString("Country")); languages.put(l.getDisplayCountry(), rs.getInt("c")); } //languages.remove("Unknown"); con.close(); } catch (IOException | SQLException | PropertyVetoException ex) { Logger.getLogger(PieGraphData.class.getName()).log(Level.SEVERE, null, ex); } finally { DbUtils.closeQuietly(con, stmt, rs); } }
From source file:org.jspringbot.keyword.i18n.I18nHelper.java
public String getDisplayCountry() { Locale locale = getLocale(); LOG.keywordAppender().appendProperty("Display Country", locale.getDisplayCountry()); return locale.getDisplayCountry(); }
From source file:SimpleRefDataExample.java
protected void processMessage(Message msg) throws Exception { HashMap<String, String> map = new HashMap<String, String>(); String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { Locale loc = new Locale("", countryCode); map.put(loc.getDisplayCountry().toLowerCase(), loc.getCountry()); }//from w ww . j av a2s .c o m //System.out.println (map); // Gson gson = null; //StringBuffer sb = new StringBuffer(); String s = null; Element securityDataArray = msg.getElement(SECURITY_DATA); int numSecurities = securityDataArray.numValues(); for (int i = 0; i < numSecurities; ++i) { Element securityData = securityDataArray.getValueAsElement(i); //System.out.println(securityData.getElementAsString(SECURITY)); Element fieldData = securityData.getElement(FIELD_DATA); for (int j = 0; j < fieldData.numElements(); ++j) { Element field = fieldData.getElement(j); if (field.isNull()) { System.out.println(field.name() + " is NULL."); } else { String str = field.getValueAsString(); if (j % 2 == 0) s = str; else { String countryCode = map.get(s.toLowerCase()); if (countryCode != null) { // System.out.println(str + " " + countryCode); //if (map.containsKey(s)) obj.put(countryCode, Double.parseDouble(str)); } } //field.getValueAsString().put(obj); //obj.put(str[0], str[1]); } } Element fieldExceptionArray = securityData.getElement(FIELD_EXCEPTIONS); for (int k = 0; k < fieldExceptionArray.numValues(); ++k) { Element fieldException = fieldExceptionArray.getValueAsElement(k); /* System.out.println( fieldException.getElement(ERROR_INFO).getElementAsString("category") + ": " + fieldException.getElementAsString(FIELD_ID));*/ } } }
From source file:eu.eubrazilcc.lvl.core.GbFlatFileTest.java
@Test public void test() { System.out.println("GbFlatFileTest.test()"); try {//from w w w.j a va2 s . c o m final Collection<File> files = getGenBankFlatFiles(); for (final File file : files) { System.out.println(" >> Sequence file: " + file.getCanonicalPath()); final ImmutableMultimap<GenBankField, Locale> countries = inferCountry(file); assertThat("inferred countries is not null", countries, notNullValue()); assertThat("inferred countries is not empty", !countries.isEmpty()); /* uncomment to display additional output */ System.out.println("Inferred countries: "); for (final GenBankField key : countries.keySet()) { for (final Locale locale : countries.get(key)) { System.out.println("Field=" + key + ", country=" + locale.getDisplayCountry()); } } } } catch (Exception e) { e.printStackTrace(System.err); fail("GbFlatFileTest.test() failed: " + e.getMessage()); } finally { System.out.println("GbFlatFileTest.test() has finished"); } }
From source file:org.megam.api.http.TransportResponse.java
public TransportResponse(StatusLine tempStatus, HttpEntity tempEntity, Locale tempLocale) throws ParseException, IOException { entity = EntityUtils.toString(tempEntity); status = tempStatus.toString();/*from w w w .ja v a2 s . co m*/ locale = tempLocale.getDisplayCountry() + ":" + tempLocale.getDisplayLanguage(); }
From source file:mo.iguideu.ui.initGuideProfile.FragmentInitGuideDataStep2.java
public void refreshSupportLocales() { String[] countries = Locale.getISOCountries(); Locale[] locales = Locale.getAvailableLocales(); Map<String, String> languagesMap = new TreeMap<String, String>(); for (Locale obj : locales) { if ((obj.getDisplayCountry() != null) && (!"".equals(obj.getDisplayCountry()))) { languagesMap.put(obj.getCountry(), obj.getLanguage()); }/*from w w w .j a v a 2 s . c om*/ } for (String countryCode : countries) { Locale obj = new Locale("", countryCode); if (languagesMap.get(countryCode) != null) { obj = new Locale(languagesMap.get(countryCode), countryCode); if (!obj.getCountry().equals("TW") && !obj.getCountry().equals("JP") && !obj.getCountry().equals("CN")) supportLocale.add(obj); } } }