Example usage for java.util Locale getDefault

List of usage examples for java.util Locale getDefault

Introduction

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

Prototype

public static Locale getDefault() 

Source Link

Document

Gets the current value of the default locale for this instance of the Java Virtual Machine.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG,
            Locale.getDefault());

    String s = dateFormat.format(new Date());
    System.out.println(s);//from w  w w .  jav  a 2 s .  c o  m

}

From source file:Main.java

public static void main(String[] args) {

    Calendar now = Calendar.getInstance();
    Locale locale = Locale.getDefault();

    // call the getdisplaynames method
    Map<String, Integer> representations = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);

    NavigableMap<String, Integer> navMap = new TreeMap<String, Integer>(representations);

    // print the results
    System.out.printf("Whole list:%n%s%n", navMap);
}

From source file:NavigableMapSample.java

public static void main(String args[]) {
    Calendar now = Calendar.getInstance();
    Locale locale = Locale.getDefault();

    Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);
    NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(names);
    System.out.printf("Whole list:%n%s%n", nav);
}

From source file:NavigableMapSample.java

public static void main(String args[]) {
    Calendar now = Calendar.getInstance();
    Locale locale = Locale.getDefault();

    Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);
    NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(names);
    System.out.printf("Whole list:%n%s%n", nav);
    System.out.printf("Key lower before Sunday: %s%n", nav.lowerKey("Sunday"));
}

From source file:NavigableMapSample.java

public static void main(String args[]) {
    Calendar now = Calendar.getInstance();
    Locale locale = Locale.getDefault();

    Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);
    NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(names);
    System.out.printf("Whole list:%n%s%n", nav);
    System.out.printf("Key ceiling after Sunday: %s%n", nav.ceilingKey("Sunday"));
}

From source file:NavigableMapSample.java

public static void main(String args[]) {
    Calendar now = Calendar.getInstance();
    Locale locale = Locale.getDefault();

    Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);
    NavigableMap<String, Integer> nav = new TreeMap<String, Integer>(names);
    System.out.printf("Whole list:%n%s%n", nav);
    System.out.printf("First key: %s\tFirst entry: %s%n", nav.firstKey(), nav.firstEntry());
}

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  .j av a  2 s  .  co  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:Animals.java

public static void main(String[] argv) {

    ResourceBundle animalResources;

    try {/*from www. j  a v  a 2s . c  om*/
        animalResources = ResourceBundle.getBundle("AnimalResources", Locale.getDefault());
        System.out.println(animalResources.getString("Animals"));
    } catch (MissingResourceException mre) {
        mre.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    Locale locale1 = new Locale("en", "US", "WIN");

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

    // set another default locale
    Locale.setDefault(new Locale("fr", "FRANCE", "MAC"));

    Locale locale2 = Locale.getDefault();

    // print the new locale
    System.out.println("Locale::" + locale2);
}

From source file:MainClass.java

public static void main(String[] args) {
    Locale locale = Locale.getDefault();
    ResourceBundle rb = ResourceBundle.getBundle("MyResources", locale);
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("I18N Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new GridLayout(3, 2));
    frame.add(new JLabel(rb.getString("userName")));
    frame.add(new JTextField());
    frame.add(new JLabel(rb.getString("password")));
    frame.add(new JPasswordField());
    frame.add(new JButton(rb.getString("login")));
    frame.pack();//w w  w .j av  a  2s .com
    frame.setVisible(true);
}