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:Main.java

/**
 * Get the raw mac address from macAddress for Mesh. It is an inverse method for getMacAddressForMesh.
 * //  w  w w.  j av  a2s.  c o m
 * @param macAddressForMesh the macAddress for Mesh
 * @return the raw mac address
 */
public static String getRawMacAddress(String macAddressForMesh) {
    StringBuilder sb = new StringBuilder();
    char c;
    for (int i = 0; i < macAddressForMesh.length(); i++) {
        c = macAddressForMesh.charAt(i);
        sb.append(c);
        if (i % 2 != 0 && i != macAddressForMesh.length() - 1) {
            sb.append(':');
        }
    }
    return sb.toString().toLowerCase(Locale.US);
}

From source file:Main.java

public static Date convertStringToDate(String dateString, String format) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format, Locale.US);
    try {/*from  w  w  w .ja v a  2 s . c  o  m*/
        return simpleDateFormat.parse(dateString.trim());
    } catch (ParseException e) {
        Log.e(TAG, e.getMessage(), e);
    }
    return null;
}

From source file:Main.java

public static String doubleToString(double d, int df) {
    String res = "";
    NumberFormat form;//w  w  w . j av a2  s . c om
    form = NumberFormat.getInstance(Locale.US);
    form.setMaximumFractionDigits(df);
    form.setGroupingUsed(false);
    try {
        res = form.format(d);
    } catch (IllegalArgumentException e) {
        res = "";
    }
    return res;
}

From source file:Main.java

public static String guessImageFormat(String urlOrPath) {
    CompressFormat format = guessImageFormatC(urlOrPath);
    if (format == null)
        return null;
    if (format == CompressFormat.JPEG)
        return "jpg";
    return format.name().toLowerCase(Locale.US);
}

From source file:Main.java

public static boolean isM4AFile(String in) {
    boolean retVal = false;

    in = in.toLowerCase(Locale.US);
    if (in.endsWith(".m4a") || in.endsWith(".m4p"))
        retVal = true;/*  ww  w  .  j  a va  2s .c o m*/

    return retVal;
}

From source file:Main.java

private static String toHexadecimalString(byte[] value) {
    StringBuffer sb = new StringBuffer();
    int len = value.length;
    for (int i = 0; i < len; i++) {
        int num = ((int) value[i]) & 0xff;
        if (num < 0x10) {
            sb.append('0');
        }//from  ww w.ja v a  2  s  .c o  m
        sb.append(Integer.toHexString(num));
        if (i < len - 1) {
            sb.append(':');
        }
    }
    return sb.toString().toUpperCase(Locale.US);
}

From source file:Main.java

/**
 * Handles String format for the default (US) Locale. This should be used for locale-agnostic
 * messages to prevent locale errors, such as commas used instead of decimals.
 * @param format/*from   ww  w .ja v  a 2 s .c o  m*/
 * @param args
 * @return
 */
public static String format(String format, Object... args) {
    return String.format(Locale.US, format, args);
}

From source file:Main.java

public static String oldEncodeQrCodeString(String text) {
    Pattern pattern = Pattern.compile("[A-Z]");
    Matcher matcher = pattern.matcher(text);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) {
        String letter = matcher.group(0);
        matcher.appendReplacement(sb, QR_CODE_LETTER + letter);
    }/*  ww  w.  ja  va 2s.  c om*/
    matcher.appendTail(sb);

    return sb.toString().toUpperCase(Locale.US);
}

From source file:Main.java

/**
 * Get the mac address String format by the device's bssid bytes format
 * @param bssidBytes the device's bssid bytes format
 * @return the mac address String format
 *///from www  . j  a  v a 2  s.  c o m
public static String getMacAddressStr(byte[] bssidBytes) {
    StringBuilder sb = new StringBuilder();
    String segmentStr = null;
    for (int i = 0; i < bssidBytes.length; ++i) {
        segmentStr = Integer.toHexString(0xff & bssidBytes[i]);
        if (segmentStr.length() == 1) {
            sb.append("0");
        }
        sb.append(segmentStr);
        if (i != bssidBytes.length - 1) {
            sb.append(':');
        }
    }
    return sb.toString().toLowerCase(Locale.US);
}

From source file:Main.java

public static boolean isWMAFile(String in) {
    return in.toLowerCase(Locale.US).endsWith(".wma");
}