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

/**
 * Get device language
 *
 * @return language code
 */
public static String getDeviceLanguage() {
    return Locale.getDefault().getLanguage();
}

From source file:Main.java

public static boolean isRTL() {
    final int directionality = Character.getDirectionality(Locale.getDefault().getDisplayName().charAt(0));
    return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT
            || directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
}

From source file:Main.java

/**
 * @return String representation of device Language code as per ISO 639
 *///  w w  w.  ja va2s . c om
public static String getLanguage() {
    return Locale.getDefault().getLanguage();
}

From source file:Main.java

private static String getTImeStamp() {
    return new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
}

From source file:Main.java

public static String getTOSLink() {
    String link = "http://m.google.com/toscountry"; // default

    String locale = Locale.getDefault().toString();
    if (locale.equals(Locale.US.toString())) {
        link = "http://m.google.com/tospage";
    } else if (locale.equals(Locale.UK.toString())) {
        link = "http://m.google.co.uk/tospage";
    } else if (locale.equals(Locale.CANADA.toString())) {
        link = "http://m.google.ca/tospage";
    } else if (locale.equals(Locale.CANADA_FRENCH.toString())) {
        link = "http://m.google.ca/tospage?hl=fr";
    } else if (locale.equals(Locale.FRANCE.toString())) {
        link = "http://m.google.fr/tospage";
    }// w w  w.  jav  a 2 s.com
    return link;
}

From source file:Main.java

/**
 * @return/*from ww  w  .  j av a  2 s  . c  om*/
 */
public static String calculateAltitudeFromMSL(float msl) {
    double altitude = msl;
    return (String.format(Locale.getDefault(), "%d", (int) altitude));
}

From source file:Main.java

public static String dateToString(Date date) {
    return new SimpleDateFormat("dd.MM.yyyy", Locale.getDefault()).format(date);
}

From source file:Main.java

public static String getTime() {
    Date currentDate = Calendar.getInstance(TimeZone.getTimeZone("JST"), Locale.getDefault()).getTime();
    /**//w w  w . j  av a2s . c  o  m
    SimpleDateFormat formatter = 
       new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy", 
                    Locale.getDefault());
     **/
    SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault());

    return formatter.format(currentDate);
}

From source file:Main.java

public static String getMonetaryValue(Double value) {
    NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.getDefault());
    return numberFormat.format(value);
}

From source file:Main.java

public static Typeface GetTypeface() {
    if ("en".equals(Locale.getDefault().getLanguage()))
        return typefaceLatoLight;
    if ("zh".equals(Locale.getDefault().getLanguage()))
        return Typeface.DEFAULT;
    return typefaceLatoLight;
}