Example usage for java.util Locale US

List of usage examples for java.util Locale US

Introduction

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

Prototype

Locale US

To view the source code for java.util Locale US.

Click Source Link

Document

Useful constant for country.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    Currency c;// w ww .j  a  v a2  s  .  com

    c = Currency.getInstance(Locale.US);

    System.out.println("Symbol: " + c.getSymbol());
    System.out.println("Default fractional digits: " + c.getDefaultFractionDigits());
}

From source file:Main.java

public static void main(String[] args) {

    StringBuffer buffer = new StringBuffer();
    Formatter formatter = new Formatter(buffer, Locale.US);

    // format a new string
    String name = "from java2s.com";
    formatter.format("Hello %s !", name);

    // print the formatted string
    System.out.println(formatter);

    // close the formatter
    formatter.close();//from w  w  w  .  j a va2  s  .  c  o  m

    // attempt to access the formatter results in exception
    System.out.println(formatter);
}

From source file:MainClass.java

public static void main(String[] a) {
    GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("America/Chicago"), Locale.US);
    System.out.println(calendar);
}

From source file:Main.java

public static void main(String[] args) {
    String s = "java2s.com 1 + 1 = 2.0 ";

    Scanner scanner = new Scanner(s);

    scanner.useLocale(Locale.US);

    while (scanner.hasNext()) {
        // check if the scanner's next token is a short with a radix 4
        System.out.println(scanner.hasNextShort(4));

        System.out.println(scanner.next());
    }//  w  w w. ja va  2  s  . c o m

    scanner.close();
}

From source file:Main.java

public static void main(String[] args) {

    ClassLoader cl = ClassLoader.getSystemClassLoader();

    ResourceBundle bundle = ResourceBundle.getBundle("hello", Locale.US, cl);

    System.out.println(bundle.getString("hello"));

}

From source file:Main.java

public static void main(String[] args) {
    double value = 1234567.89;

    System.out.println("Unformatted: " + value + "\n");

    Locale locales[] = { Locale.US, Locale.FRANCE, Locale.GERMANY, Locale.JAPAN, new Locale("fr", "FR", "EURO"),
            new Locale("de", "DE", "EURO") };

    for (int i = 0; i < locales.length; i++) {
        NumberFormat nf = NumberFormat.getCurrencyInstance(locales[i]);

        System.out.println("Formatted for " + locales[i] + ": " + nf.format(value));
    }/*from  ww w. j a v  a 2s. co  m*/
}

From source file:Main.java

public static void main(String[] args) {
    BigDecimal payment = new BigDecimal("12345.67");
    NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
    double doublePayment = payment.doubleValue();
    String s = n.format(doublePayment);
    System.out.println(s);//from  w w  w. j a v  a  2 s.  c o m
}

From source file:Main.java

public static void main(String[] args) {

    String s = "java2s.com 1 + 1 = 2.0 true";

    Scanner scanner = new Scanner(s);

    scanner.useLocale(Locale.US);

    while (scanner.hasNext()) {

        // if the next is a double, print found and the double
        if (scanner.hasNextDouble()) {
            System.out.println("Found :" + scanner.nextDouble());
        }/* w w  w .j  ava2  s . c o m*/

        // if a double is not found, print "Not Found" and the token
        System.out.println("Not Found :" + scanner.next());
    }

    scanner.close();
}

From source file:MainClass.java

public static void main(String[] args) {
    Date today = new Date();
    DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.US);
    String formatted = fmt.format(today);
    System.out.println(formatted);
}

From source file:DisplayVariantOutput.java

public static void main(String[] argv) {

    Locale defaultLocale = Locale.getDefault();
    System.out.println(defaultLocale.getDisplayVariant());
    System.out.println(defaultLocale.getDisplayVariant(Locale.US));
    System.out.println((new Locale("en", "US", "WIN_TX_Austin")).getDisplayVariant());
}