List of usage examples for java.util Locale Locale
public Locale(String language, String country)
From source file:Main.java
public static void main(String[] args) { Date today = new Date(); // Print date in the default locale format Locale defaultLocale = Locale.getDefault(); printLocaleDetails(defaultLocale);//from ww w .ja va2 s .c o m printDate(defaultLocale, today); // Print date in French format printLocaleDetails(Locale.FRANCE); printDate(Locale.FRANCE, today); // Print date in German format. We could also use Locale.GERMANY // instead of new Locale ("de", "DE"). Locale germanLocale = new Locale("de", "DE"); printLocaleDetails(germanLocale); printDate(germanLocale, today); }
From source file:org.springforpro.chptr5.context.MessageSourceDemo.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:appContext/messageSource.xml"); ctx.refresh();/*from www . jav a2 s . c o m*/ Locale english = Locale.ENGLISH; Locale russian = new Locale("ru", "RU"); System.out.println("English msg: " + ctx.getMessage("msg", null, english)); System.out.println("Russian msg: " + ctx.getMessage("msg", null, russian)); System.out .println("English nameMsg" + ctx.getMessage("nameMsg", new Object[] { "Clarence", "Ho" }, english)); // ResourceBundleMessageSource source = new ResourceBundleMessageSource(); // StaticMessageSource source = new StaticMessageSource(); // source.setBasename("appContext/labels"); // System.out.println(source.getMessage("msg", null, russian) ); // System.out.println(source.getMessage("msg", null, english) ); // Object[] os = new Object[] {"One", "two"}; // System.out.println(source.getMessage("nameMsg", new Object[] {"wut", "in my butt"}, english)); }
From source file:com.home.ln_spring.ch5.context.MessageSourceDemo.java
public static void main(String[] args) { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load("classpath:appContext/messageSource.xml"); context.refresh();// w w w . jav a 2s . c om Locale english = Locale.ENGLISH; Locale czech = new Locale("cs", "CZ"); System.out.println(context.getMessage("msg", null, english)); System.out.println(context.getMessage("msg", null, czech)); System.out.println( context.getMessage("nameMsg", new Object[] { "Dynisyuk", "Vitaliy", "Vladimirovich" }, english)); }
From source file:AntarcticaLocaleDemo.java
public static void main(String [] args) { Date now = new Date(); DateFormat defaultFormat = DateFormat.getDateTimeInstance(); String defaultString = defaultFormat.format (now); System.out.println ("Default : " + defaultString); DateFormat antarcticaFormat = DateFormat.getDateTimeInstance ( DateFormat.FULL, DateFormat.FULL, new Locale ("en", "AQ")); String antarcticaString = antarcticaFormat.format (now); System.out.println ("Antarctica: " + antarcticaString); }
From source file:br.com.etec.Main.java
@SuppressWarnings("ALL") public static void main(String args[]) { Locale.setDefault(new Locale("pt", "BR")); SwingUtilities.invokeLater(new Runnable() { @Override/*from w ww .j a v a 2 s.c o m*/ public void run() { try { // Define o look and feel. initLookAndFeel(); installSmartLookAndFeel(); } catch (Exception ex) { LOGGER.log(Level.WARN, null, ex); } finally { new ClassPathXmlApplicationContext("META-INF/spring-config.xml"); } } }); }
From source file:Main.java
public static void main(String[] args) { LocalDate ld = LocalDate.of(2014, Month.JUNE, 21); LocalTime lt = LocalTime.of(17, 30, 20); LocalDateTime ldt = LocalDateTime.of(ld, lt); DateTimeFormatter fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT); System.out.println("Formatter Default Locale: " + fmt.getLocale()); System.out.println("Short Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM); System.out.println("Medium Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); System.out.println("Long Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL); System.out.println("Full Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT); System.out.println("Short Time: " + fmt.format(lt)); fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT); System.out.println("Short Datetime: " + fmt.format(ldt)); fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); System.out.println("Medium Datetime: " + fmt.format(ldt)); // Use German locale to format the datetime in medius style fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.GERMAN); System.out.println(fmt.format(ldt)); // Use Indian(English) locale to format datetime in short style fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withLocale(new Locale("en", "IN")); System.out.println(fmt.format(ldt)); // Use Indian(English) locale to format datetime in medium style fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(new Locale("en", "IN")); System.out.println(fmt.format(ldt)); }
From source file:br.com.thiagomoreira.bancodobrasil.Main.java
/** * @param args//from ww w .j a v a 2s. c o m */ public static void main(String[] args) throws Exception { if (args != null) { NumberFormat formatter = NumberFormat.getNumberInstance(new Locale("pt", "BR")); formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(2); double total = 0; for (String arg : args) { File input = new File(arg); if (input.exists()) { List<String> lines = IOUtils.readLines(new FileInputStream(input), "ISO-8859-1"); Parser parser = new DefaultParser(); List<Transaction> transactions = parser.parse(lines); TransactionList transactionList = new TransactionList(); transactionList.setStart(parser.getStartDate()); transactionList.setEnd(parser.getEndDate()); transactionList.setTransactions(transactions); CreditCardAccountDetails creditCardAccountDetails = new CreditCardAccountDetails(); creditCardAccountDetails.setAccountNumber("7616-3"); creditCardAccountDetails.setAccountKey(parser.getAccountKey()); CreditCardStatementResponse creditCardStatementResponse = new CreditCardStatementResponse(); creditCardStatementResponse.setAccount(creditCardAccountDetails); creditCardStatementResponse.setCurrencyCode("BRL"); creditCardStatementResponse.setTransactionList(transactionList); Status status = new Status(); status.setCode(Status.KnownCode.SUCCESS); status.setSeverity(Status.Severity.INFO); CreditCardStatementResponseTransaction statementResponse = new CreditCardStatementResponseTransaction(); statementResponse.setClientCookie(UUID.randomUUID().toString()); statementResponse.setStatus(status); statementResponse.setUID(UUID.randomUUID().toString()); statementResponse.setMessage(creditCardStatementResponse); CreditCardResponseMessageSet creditCardResponseMessageSet = new CreditCardResponseMessageSet(); creditCardResponseMessageSet.setStatementResponse(statementResponse); SortedSet<ResponseMessageSet> messageSets = new TreeSet<ResponseMessageSet>(); messageSets.add(creditCardResponseMessageSet); ResponseEnvelope envelope = new ResponseEnvelope(); envelope.setUID(UUID.randomUUID().toString()); envelope.setSecurity(ApplicationSecurity.NONE); envelope.setMessageSets(messageSets); double brazilianRealsamount = parser.getBrazilianRealsAmount(); double dolarsAmount = parser.getDolarsAmount(); double cardTotal = dolarsAmount * parser.getExchangeRate() + brazilianRealsamount; total += cardTotal; System.out.println(creditCardAccountDetails.getAccountKey()); System.out.println("TOTAL EM RS " + formatter.format(brazilianRealsamount)); System.out.println("TOTAL EM US " + formatter.format(dolarsAmount)); System.out.println("TOTAL FATURA EM RS " + formatter.format(cardTotal)); System.out.println(); if (!transactions.isEmpty()) { String parent = System.getProperty("user.home") + "/Downloads"; String fileName = arg.replace(".txt", ".ofx"); File output = new File(parent, fileName); FileOutputStream fos = new FileOutputStream(output); OFXV1Writer writer = new OFXV1Writer(fos); writer.setWriteAttributesOnNewLine(true); AggregateMarshaller marshaller = new AggregateMarshaller(); marshaller.setConversion(new MyFinanceStringConversion()); marshaller.marshal(envelope, writer); writer.flush(); writer.close(); } } } System.out.println("TOTAL FATURAS EM RS " + formatter.format(total)); } }
From source file:GetAppInfo.java
/** * @param args//ww w . j av a2s .c o m */ public static void main(String[] args) { if (args.length != 4) { System.out.println("Usage :\n" + "java -jar this_jar_name confpath query_str startIndex numbers"); System.exit(1); } String confpath = args[0]; GetAppConfig conf = new GetAppConfig(confpath); String email = conf.getUserID(); String password = conf.getPassword(); String query = args[1]; final int startIndex = Integer.parseInt(args[2]); final int numbers = Integer.parseInt(args[3]); String androidid = conf.getDeviceID(); if (email.equals("")) { System.out.println("Error: Failed to get UserID."); System.exit(2); } else if (password.equals("")) { System.out.println("Error: Failed to get Password."); System.exit(3); } else if (androidid.equals("")) { System.out.println("Error: Failed to get DeviceID."); System.exit(4); } System.out.println("query: " + query); MarketSession session = new MarketSession(); session.getContext().setAndroidId(androidid); Locale locale = new Locale("ja", "JP"); session.setLocale(locale); session.setOperator("NTT DOCOMO", "44010"); session.getContext().setDeviceAndSdkVersion("passion:8"); try { session.login(email, password, androidid); } catch (Exception e) { System.out.println("Error: failed to login.: " + e.getMessage()); System.exit(1); } AppsRequest appsRequest = AppsRequest.newBuilder().setQuery(query).setStartIndex(startIndex) .setEntriesCount(numbers).setWithExtendedInfo(true).build(); Callback<AppsResponse> callback = new Callback<AppsResponse>() { @Override public void onResult(ResponseContext context, AppsResponse response) { int totalcnt, cnt; JsonFactory factory = new JsonFactory(); try { JsonGenerator generator = factory.createGenerator(new FileWriter(new File("pkginfo.json"))); generator.writeStartObject(); //generator.setRootValueSeparator(new SerializedString("\n")); if (response != null) { totalcnt = response.getEntriesCount(); cnt = response.getAppCount(); System.out.println("startIndex = " + startIndex); System.out.println("entriesCount = " + numbers); System.out.println("totalcount = " + totalcnt); System.out.println("count = " + cnt); generator.writeNumberField("startIndex", startIndex); generator.writeNumberField("entriesCount", numbers); generator.writeNumberField("total", totalcnt); generator.writeNumberField("count", cnt); generator.writeRaw("\n"); } else { cnt = -1; } generator.writeFieldName("dataset"); generator.writeStartArray(); if (cnt > 0) { for (int i = 0; ((i < cnt) && (i < numbers)); i++) { generator.writeStartObject(); generator.writeNumberField("num", i + startIndex); System.out.println( "------------------------------------------------------------------------------------"); int counter = i + startIndex; System.out.println(counter + ":"); System.out.println( "------------------------------------------------------------------------------------"); generator.writeStringField("title", response.getApp(i).getTitle()); generator.writeStringField("appType", "" + response.getApp(i).getAppType()); generator.writeStringField("category", response.getApp(i).getExtendedInfo().getCategory()); generator.writeStringField("rating", response.getApp(i).getRating()); generator.writeNumberField("ratingCount", response.getApp(i).getRatingsCount()); generator.writeStringField("countText", response.getApp(i).getExtendedInfo().getDownloadsCountText()); generator.writeStringField("creatorId", response.getApp(i).getCreatorId()); generator.writeStringField("id", response.getApp(i).getId()); generator.writeStringField("packageName", response.getApp(i).getPackageName()); generator.writeStringField("version", response.getApp(i).getVersion()); generator.writeNumberField("versionCode", response.getApp(i).getVersionCode()); generator.writeStringField("price", response.getApp(i).getPrice()); generator.writeNumberField("priceMicros", response.getApp(i).getPriceMicros()); generator.writeStringField("priceCurrency", response.getApp(i).getPriceCurrency()); generator.writeStringField("contactWebsite", response.getApp(i).getExtendedInfo().getContactWebsite()); generator.writeNumberField("screenshotsCount", response.getApp(i).getExtendedInfo().getScreenshotsCount()); generator.writeNumberField("installSize", response.getApp(i).getExtendedInfo().getInstallSize()); generator.writeStringField("permissionIdList", "" + response.getApp(i).getExtendedInfo().getPermissionIdList()); generator.writeStringField("promotoText", response.getApp(i).getExtendedInfo().getPromoText()); generator.writeStringField("description", response.getApp(i).getExtendedInfo().getDescription()); System.out.println("title: " + response.getApp(i).getTitle()); System.out.println("appType: " + response.getApp(i).getAppType()); System.out.println("category: " + response.getApp(i).getExtendedInfo().getCategory()); System.out.println("rating: " + response.getApp(i).getRating()); System.out.println("ratingsCount: " + response.getApp(i).getRatingsCount()); System.out .println("count: " + response.getApp(i).getExtendedInfo().getDownloadsCount()); System.out.println( "countText: " + response.getApp(i).getExtendedInfo().getDownloadsCountText()); System.out.println("creator: " + response.getApp(i).getCreator()); System.out.println("creatorId: " + response.getApp(i).getCreatorId()); System.out.println("id: " + response.getApp(i).getId()); System.out.println("packageName: " + response.getApp(i).getPackageName()); System.out.println("version: " + response.getApp(i).getVersion()); //System.out.println("contactEmail: " + response.getApp(i).getExtendedInfo().getContactEmail()); //System.out.println("contactPhone: " + response.getApp(i).getExtendedInfo().getContactPhone()); System.out.println( "installSize: " + response.getApp(i).getExtendedInfo().getInstallSize()); generator.writeEndObject(); generator.writeRaw("\n"); } } else if (cnt == 0) { System.out.println("no hit"); } else { System.out.println("Bad Reqeust"); } generator.writeEndArray(); generator.writeEndObject(); generator.close(); } catch (Exception e) { System.out.println("Error: pkginfo(): " + e.getMessage()); } } // onResult() }; session.append(appsRequest, callback); session.flush(); }
From source file:CollatorDemo.java
static public void main(String[] args) { testCompare();/* w ww.j a va 2s. c o m*/ System.out.println(); Collator fr_FRCollator = Collator.getInstance(new Locale("fr", "FR")); Collator en_USCollator = Collator.getInstance(new Locale("en", "US")); String eWithCircumflex = new String("\u00EA"); String eWithAcute = new String("\u00E9"); String peachfr = "p" + eWithAcute + "ch" + eWithAcute; String sinfr = "p" + eWithCircumflex + "che"; String[] words = { peachfr, sinfr, "peach", "sin" }; sortStrings(fr_FRCollator, words); System.out.println("Locale: fr_FR"); printStrings(words); System.out.println(); sortStrings(en_USCollator, words); System.out.println("Locale: en_US"); printStrings(words); }
From source file:RBCPTest.java
public static void main(String[] args) { ResourceBundle rb = ResourceBundle.getBundle("resources.XmlRB", Locale.ROOT); String type = rb.getString("type"); System.out.println("Root locale. Key, type: " + type); System.out.println();// w ww. ja va 2s .co m rb = ResourceBundle.getBundle("resources.XmlRB", Locale.JAPAN); type = rb.getString("type"); System.out.println("Japan locale. Key, type: " + type); System.out.println(); test(Locale.CHINA); test(new Locale("zh", "HK")); test(Locale.TAIWAN); test(Locale.CANADA); }