Example usage for java.util Locale ENGLISH

List of usage examples for java.util Locale ENGLISH

Introduction

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

Prototype

Locale ENGLISH

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

Click Source Link

Document

Useful constant for language.

Usage

From source file:Main.java

private static String intToHex2(final int i) {
    final char hex_2[] = { Character.forDigit((i >> 4) & 0x0f, 16), Character.forDigit(i & 0x0f, 16) };
    return new String(hex_2).toUpperCase(Locale.ENGLISH);
}

From source file:Main.java

/**
 * Constructs a key string from the received deviceId and the appId
 * //w  w w  .  jav a2 s.com
 * @param deviceId
 * @param appId
 * @return key
 */
public static String getKey(String deviceId, UUID appId) {

    String appIdStr = appId.toString().replace("-", "");
    return deviceId + "_" + appIdStr.toUpperCase(Locale.ENGLISH);
}

From source file:Main.java

public static int str2int(String s, int defVal) {
    if (s.equals("N/A"))
        return defVal;
    try {//  w  w  w.j ava  2s.  c o  m
        s = s.trim();
        s = s.contains(" ") ? s.split(" ")[0] : s;
        return NumberFormat.getInstance(Locale.ENGLISH).parse(s).intValue();
    } catch (Exception err) {
        Log.e("str2int", s, err);
        return defVal;
    }
}

From source file:Main.java

/** -----------------------------------------------------------------------  Google Maps -- */

public static Intent newOpenMapsAtLatLongAndName(String latitude, String longitude, String name) {
    Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse(String.format(Locale.ENGLISH, "geo:%s,%s", latitude, longitude) + "?q="
                    + Uri.encode(latitude + "," + longitude + "(" + name + ")") + "&z=16"));
    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    return intent;
}

From source file:Main.java

/**
 * Convert Date to String - For Audio Record FileName ONLY
 * @param date/*from  w  w w  .ja  v  a2  s  .c  om*/
 * @param format
 * @return
 */
public static String convertDateToStrForAudioFileName() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ENGLISH);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+0000"));
    String dateStr = dateFormat.format(new Date());
    return dateStr;
}

From source file:Main.java

public static String dateToFormattedString(Date date, String formatString) {
    SimpleDateFormat format = new SimpleDateFormat(formatString, Locale.ENGLISH);
    return format.format(date);
}

From source file:Main.java

public static String dashToCamelCase(String name, boolean firstLetterUpper) {
    int currIndex = 0, dashIndex;
    StringBuilder camelName = new StringBuilder(name.length());
    if (firstLetterUpper && !name.isEmpty()) {
        camelName.append(String.valueOf(name.charAt(0)).toUpperCase(Locale.ENGLISH));
        currIndex = 1;/*from w  ww  . j  a v a 2 s .com*/
    }
    while (currIndex < name.length() && (dashIndex = name.indexOf('-', currIndex)) >= 0) {
        camelName.append(name.substring(currIndex, dashIndex));
        if (dashIndex + 1 < name.length()) {
            camelName.append(String.valueOf(name.charAt(dashIndex + 1)).toUpperCase(Locale.ENGLISH));
        }
        currIndex = dashIndex + 2;
    }
    if (currIndex < name.length()) {
        camelName.append(name.substring(currIndex));
    }
    return camelName.toString();
}

From source file:Main.java

public static String getRelativeTimeAgo(String rawJsonDate) {
    String twitterFormat = "EEE MMM dd HH:mm:ss ZZZZZ yyyy";
    SimpleDateFormat sf = new SimpleDateFormat(twitterFormat, Locale.ENGLISH);
    sf.setLenient(true);//  ww  w  .  j  a v a 2  s  .  c om

    String relativeDate = "";
    try {
        long dateMillis = sf.parse(rawJsonDate).getTime();
        relativeDate = DateUtils
                .getRelativeTimeSpanString(dateMillis, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS)
                .toString();
    } catch (ParseException e) {
        e.printStackTrace();
    }

    // Shorten relative date
    relativeDate = relativeDate.replaceAll(" ", "").replace("seconds", "s").replace("second", "s")
            .replace("minutes", "m").replace("minute", "m").replace("hours", "h").replace("hour", "h")
            .replace("days", "d").replace("day", "d").replace("weeks", "w").replace("week", "w")
            .replace("months", "M").replace("month", "M").replace("years", "y").replace("year", "y")
            .replace("ago", "").replace("in", "").replace("0s", "just now");

    return relativeDate;
}

From source file:Main.java

public static String getCurrentDateFilename(String extension) {
    return new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ENGLISH).format(new Date()) + "." + extension;
}

From source file:Main.java

/**
 * Formats the passed milliseconds to the defined pattern
 *
 * @param pattern      time/date pattern
 * @param milliSeconds milliseconds//ww w  . j  a va2s.  c  om
 * @return formatted time/date
 */
public static String getFormattedDate(String pattern, long milliSeconds) {
    return new SimpleDateFormat(pattern, Locale.ENGLISH).format(new Date(milliSeconds));
}