List of usage examples for java.util Locale Locale
public Locale(String language, String country)
From source file:DateFormatDemo.java
static public void main(String[] args) { Locale[] locales = { new Locale("fr", "FR"), new Locale("de", "DE"), new Locale("en", "US") }; for (int i = 0; i < locales.length; i++) { displayDate(locales[i]);/*from w w w . java 2s .c om*/ } showDateStyles(new Locale("en", "US")); showDateStyles(new Locale("fr", "FR")); showTimeStyles(new Locale("en", "US")); showTimeStyles(new Locale("de", "DE")); showBothStyles(new Locale("en", "US")); showBothStyles(new Locale("fr", "FR")); }
From source file:org.key2gym.client.Main.java
/** * The main method which performs all the task described in the class * description.// www . ja v a2s . c o m * * @param args an array of arguments */ public static void main(String[] args) { /* * Configures the logger using 'etc/logging.properties' or the default * logging properties file. */ try (InputStream input = new FileInputStream(PATH_LOGGING_PROPERTIES)) { PropertyConfigurator.configure(input); } catch (IOException ex) { try (InputStream input = Thread.currentThread().getContextClassLoader() .getResourceAsStream(RESOURCE_DEFAULT_LOGGING_PROPERTIES)) { PropertyConfigurator.configure(input); /* * Notify that the default logging properties file has been * used. */ logger.info("Could not load the logging properties file"); } catch (IOException ex2) { throw new RuntimeException("Failed to initialize logging system", ex2); } } logger.info("Starting..."); /* * Loads the built-in default properties file. */ try (InputStream input = Thread.currentThread().getContextClassLoader() .getResourceAsStream(RESOURCE_DEFAULT_CLIENT_PROPERTIES)) { Properties defaultProperties = null; defaultProperties = new Properties(); defaultProperties.load(input); properties.putAll(defaultProperties); } catch (IOException ex) { throw new RuntimeException("Failed to load the default client properties file", ex); } /* * Loads the local client properties file. */ try (FileInputStream input = new FileInputStream(PATH_APPLICATION_PROPERTIES)) { Properties localProperties = null; localProperties = new Properties(); localProperties.load(input); properties.putAll(localProperties); } catch (IOException ex) { if (logger.isEnabledFor(Level.DEBUG)) { logger.debug("Failed to load the client properties file", ex); } else { logger.info("Could not load the local client properties file"); } /* * It's okay to start without the local properties file. */ } logger.debug("Effective properties: " + properties); if (properties.containsKey(PROPERTY_LOCALE_COUNTRY) && properties.containsKey(PROPERTY_LOCALE_LANGUAGE)) { /* * Changes the application's locale. */ Locale.setDefault(new Locale(properties.getProperty(PROPERTY_LOCALE_LANGUAGE), properties.getProperty(PROPERTY_LOCALE_COUNTRY))); } else { logger.debug("Using the default locale"); } /* * Changes the application's L&F. */ String ui = properties.getProperty(PROPERTY_UI); try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if (ui.equalsIgnoreCase(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { logger.error("Failed to change the L&F:", ex); } SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL); // Loads the client application context context = new ClassPathXmlApplicationContext("META-INF/client.xml"); logger.info("Started!"); launchAndWaitMainFrame(); logger.info("Shutting down!"); context.close(); }
From source file:Main.java
public static String iso2CountryCodeToCountryName(String iso2CountryCode) { Locale locale = new Locale(loc, iso2CountryCode); return locale.getDisplayCountry(); }
From source file:Main.java
public static String getFormattedValue(double value) { NumberFormat nf = NumberFormat.getCurrencyInstance(new Locale("pt", "BR")); return nf.format(value); }
From source file:Main.java
public static DateFormat GetFileNameDateFormatter() { Locale loc = new Locale("en", "US"); SimpleDateFormat df = new SimpleDateFormat("MM.dd.yy.h.mm.ss", loc); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df;//ww w .ja v a 2 s .c o m }
From source file:Main.java
public static String formatDate(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy", new Locale("pt", "br")); return dateFormat.format(date); }
From source file:Main.java
public static String getSpinnertextCountry(String countryCode) { Locale locale = new Locale("", countryCode); try {/*from w ww .ja va 2s . c o m*/ Currency currency = Currency.getInstance(locale); return locale.getDisplayCountry() + " (" + currency.getCurrencyCode() + ")"; } catch (Exception e) { } return ""; }
From source file:Main.java
public static String toReal(Double value) { NumberFormat numberFormat = NumberFormat.getCurrencyInstance(new Locale("pt", "BR")); return numberFormat.format(value).replace("R$", "R$ "); }
From source file:Main.java
public static String formatMoneyAmountOne(double amount) { Locale locale = new Locale("ru", "RU"); NumberFormat format = NumberFormat.getCurrencyInstance(locale); format.setMinimumFractionDigits(0);/*from w ww. j a va 2s. c om*/ format.setMaximumFractionDigits(1); String amountTxt = format.format(amount); String amountTxtValue = ""; for (int i = 0; i < amountTxt.length(); i++) { if (Character.isDigit(amountTxt.charAt(i)) || amountTxt.charAt(i) == '.' || amountTxt.charAt(i) == ',') amountTxtValue = amountTxtValue + amountTxt.charAt(i); } amountTxt = amountTxtValue; if (amountTxt.endsWith(",00")) return (amountTxt.replace(",00", "")); else if (amountTxt.endsWith("0") && amountTxt.contains(",")) { return (amountTxt.substring(0, amountTxt.length() - 1)); } else return (amountTxt); }
From source file:Main.java
public static String convertToCurrencyFormat(String amount) { double amountDouble = Double.parseDouble(amount); NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "IN")); String returnString = formatter.format(amountDouble).replace("Rs.", ""); return returnString.replace("Rs", "").trim(); }