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 String formatPrice(double price) {
    return String.format(Locale.getDefault(), "%.1f", price);
}

From source file:Main.java

public static String formatAmount(double value) {
    return String.format(Locale.getDefault(), "%.2f", value);
}

From source file:Main.java

public static String getDefaultLocale() {
    switch (Locale.getDefault().getLanguage()) {
    case "zh":
        switch (Locale.getDefault().getCountry()) {
        case "CN":
            return Locale.SIMPLIFIED_CHINESE.toString();
        default:/* w  w w.j ava  2s  .c o m*/
            return Locale.TRADITIONAL_CHINESE.toString();
        }
    case "ja":
        return Locale.JAPANESE.toString();
    default:
        return Locale.ENGLISH.toString();
    }
}

From source file:Main.java

public static boolean isChina() {
    return Locale.getDefault().getLanguage().equals("zh");
}

From source file:Main.java

public static String GetPurePercentString(double percent) {
    if ("zh".equals(Locale.getDefault().getLanguage()))
        return " " + String.format("%.2f", percent) + "%";
    else//from  ww w  .jav a2s. co  m
        return " " + String.format("%.2f", percent) + "%";
}

From source file:Main.java

public static boolean isLanguageJa() {
    return Locale.JAPANESE.toString().equalsIgnoreCase(Locale.getDefault().getLanguage());
}

From source file:Main.java

public static boolean isDeviceTeluguLocaleSelected() {

    String locale = Locale.getDefault().getLanguage();

    if (locale != null && locale.equals("te")) {

        return true;
    } else {//from  w ww  . j a v a  2  s .  c  o  m

        return false;
    }

}

From source file:Main.java

private static String toProperCase(String s) {
    return s.trim().substring(0, 1).toUpperCase(Locale.getDefault())
            + s.substring(1).toLowerCase(Locale.getDefault());
}

From source file:Main.java

public static String getConuntry(Context context) {
    return Locale.getDefault().getCountry();
}

From source file:Main.java

public static String getLanguage(Context context) {
    return Locale.getDefault().getLanguage();
}