Example usage for java.util Locale Locale

List of usage examples for java.util Locale Locale

Introduction

In this page you can find the example usage for java.util Locale Locale.

Prototype

public Locale(String language) 

Source Link

Document

Construct a locale from a language code.

Usage

From source file:Main.java

public static void main(String[] args) {
    Locale locale = new Locale("ENGLISH");

    System.out.println("Locale:" + locale);

    System.out.println("Display Name:" + locale.getDisplayCountry());

}

From source file:Main.java

public static void main(String[] args) {
    Locale locale = new Locale("ENGLISH");

    System.out.println("Locale:" + locale);

    System.out.println(locale.toLanguageTag());

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    System.out.println(NumberFormat.getInstance(new Locale("us")).format(12345.12345));

}

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // french date formatting (1. avril 2014)
    String frenchDate = dateTime.format(DateTimeFormatter.ofPattern("d. MMMM yyyy", new Locale("fr")));

    System.out.println(frenchDate);
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    String laDate = "2014-06-15";
    String dateString = laDate.substring(8, 10) + "/" + laDate.substring(5, 7) + "/" + laDate.substring(0, 4);
    Date date = new SimpleDateFormat("dd/MM/yyyy").parse(dateString);
    String dateFormat = "dd-MMM-yyyy";
    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, new Locale("en_US"));
    String tDate = sdf.format(date);
    System.out.println(tDate);/*w  w w . j a v a 2s. c om*/

}

From source file:Main.java

public static void main(String[] args) {
    // 2014-04-01 10:45
    LocalDateTime dateTime = LocalDateTime.of(2014, Month.APRIL, 1, 10, 45);

    // using short german date/time formatting (01.04.14 10:45)
    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
            .withLocale(new Locale("de"));
    String germanDateTime = dateTime.format(formatter);

    System.out.println(germanDateTime);
}

From source file:czlab.xlib.CU.java

public static void main(String[] args) {
    try {/*  www.  j av a 2s.c  o m*/
        /*
              "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
              "`~!@#$%^&*()-_+={}[]|\:;',.<>?/'"
        */
        //      String script = "(fn [_] {:a 1} )";
        //      IFn fn = (IFn)RT.var("clojure.core", "eval").invoke(RT.var("clojure.core","read-string").invoke(script));
        //      Object obj = fn.invoke("Hello");
        //      Map<?,?> m= (Map<?,?>)obj;
        //      Keyword k= Keyword.intern("a");
        //      System.out.println("obj= " + m.get(k));
        //System.out.println(shuffle("0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"));
        //      URLCodec cc = new URLCodec("utf-8");
        //      System.out.println(cc.encode("hello\u0000world"));
        //      String[] rc= StringUtils.split(",;,;,;", ",;");
        String rc = new Locale("en").toString();
        rc = null;

    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:org.pgptool.gui.app.EntryPoint.java

public static void main(String[] args) {
    DOMConfigurator.configure(EntryPoint.class.getClassLoader().getResource("pgptool-gui-log4j.xml"));
    log.info("EntryPoint first scream");

    SplashScreenView splashScreenView = null;
    try {/*from ww  w .j  a  va 2s.  c  o m*/
        args = OsNativeApiResolver.resolve().getCommandLineArguments(args);
        if (!isContinueStartupSequence(args)) {
            System.exit(0);
            return;
        }

        UiUtils.setLookAndFeel();
        splashScreenView = new SplashScreenView();
        SwingPmSettings.setBindingContextFactory(new BindingContextFactoryImpl());

        // Startup application context
        String[] contextPaths = new String[] { "app-context.xml" };
        currentApplicationContext = new ClassPathXmlApplicationContext(contextPaths);
        log.debug("App context loaded");
        LocaleContextHolder.setLocale(new Locale(System.getProperty("user.language")));
        currentApplicationContext.registerShutdownHook();
        log.debug("Shutdown hook registered");

        // Now startup application logic
        EntryPoint entryPoint = currentApplicationContext.getBean(EntryPoint.class);
        log.debug("EntryPoint bean resolved");
        prefetchKeys();
        splashScreenView.close();
        splashScreenView = null;
        entryPoint.startUp(args);
        rootPmStatic = entryPoint.getRootPm();
        log.debug("RootPM bean resolved");
        processPendingArgsIfAny(rootPmStatic);
    } catch (Throwable t) {
        log.error("Failed to startup application", t);
        reportAppInitFailureMessageToUser(t);
        // throw new RuntimeException("Application failed to start", t);
        System.exit(-1);
    } finally {
        if (splashScreenView != null) {
            splashScreenView.close();
            splashScreenView = null;
        }
    }
}

From source file:Main.java

public static String normalizeLanguageCode(String language) {
    return language == null ? null : new Locale(language).getLanguage();
}

From source file:Main.java

public static String wordSpace(String source) {
    BreakIterator boundary = BreakIterator.getLineInstance(new Locale("th"));
    boundary.setText(source);/*w w w . ja v a2s  . c  om*/
    int start = boundary.first();
    StringBuffer wordbuffer = new StringBuffer("");
    for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) {
        wordbuffer.append(source.substring(start, end) + "\u200b");
        //           wordbuffer.append(source.substring(start, end)+"\ufeff");
    }
    return wordbuffer.toString();
}