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

@TargetApi(Build.VERSION_CODES.KITKAT)
public static String[] get_Currency_Name_And_Currency_Code(String iso2) {
    String[] str = new String[2];
    Locale locale = new Locale("", iso2);
    Currency currency = Currency.getInstance(locale);
    str[0] = currency.getDisplayName(Locale.ENGLISH);
    str[1] = currency.toString();/*from   w w w  .  j a v a 2 s .c om*/
    return str;

}

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);/*  w  ww .  j a v  a 2  s .  c  o m*/

    String relativeDate = "";

    Date date;
    try {
        date = sf.parse(rawJsonDate);
        relativeDate = getTimeString(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return relativeDate;
}

From source file:Main.java

/**
 * Convert Date to String in HK TimeZone
 * @param date/*from  w ww .  ja  v a 2 s .co m*/
 * @param format Format of the output string (e.g. "yyyy-MM-dd HH:mm:ss", "HH:mm:ss")
 * @return output string
 */
public static String convertDateToStr(Date date, String format) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+0000"));
    String dateStr = "";
    if (date != null) {
        dateStr = dateFormat.format(date);
    } else {
        dateStr = dateFormat.format(new Date());
    }
    return dateStr;
}

From source file:Main.java

public static String toMatchString(List<String> terms) {
    StringBuilder builder = new StringBuilder();
    for (String term : terms) {
        if (builder.length() != 0) {
            builder.append(' ');
        }/* ww w  .j a  v  a2s.c  om*/
        if (isKeyword(term)) {
            builder.append(term.toUpperCase(Locale.ENGLISH));
        } else if (term.contains("*") || term.startsWith("-")) {
            builder.append(term);
        } else {
            builder.append('*').append(term).append('*');
        }
    }
    return builder.toString();
}

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 a  va  2s. co  m*/
            return Locale.TRADITIONAL_CHINESE.toString();
        }
    case "ja":
        return Locale.JAPANESE.toString();
    default:
        return Locale.ENGLISH.toString();
    }
}

From source file:Main.java

private static String byteToHexStr(byte[] input) {
    if (input == null) {
        return "";
    }//from  ww  w .j a v  a  2s. com
    String output = "";
    String tmp = "";
    for (int n = 0; n < input.length; n++) {
        tmp = Integer.toHexString(input[n] & 0xFF);
        if (tmp.length() == 1) {
            output = output + "0" + tmp;
        } else {
            output = output + tmp;
        }
    }
    return output.toUpperCase(Locale.ENGLISH);
}

From source file:Main.java

public static Date getDateFromString(String dateString) {

    DateFormat inputFormat = null;

    if (dateString == null) {
        return null;
    }// ww  w.  j a v a2 s.  c  o m

    if (dateString.length() == 19)
        inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
    if (dateString.length() == 10)
        inputFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);

    if (inputFormat == null) {
        return null;
    }

    inputFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date parsed = null;
    try {
        parsed = inputFormat.parse(dateString);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return parsed;
}

From source file:Main.java

public static boolean isURI(String str) {

    if (str.indexOf(':') == -1)
        return false;
    str = str.toLowerCase(Locale.ENGLISH).trim();

    if (!str.startsWith("http://") && !str.startsWith("https://") && !str.startsWith("ftp://"))
        return false;

    try {//w ww  .ja  v  a  2s. c o  m

        URI uri = new URI(str);
        String proto = uri.getScheme();

        if (proto == null)
            return false;

        if (proto.equals("http") || proto.equals("https") || proto.equals("ftp")) {

            if (uri.getHost() == null)
                return false;

            String path = uri.getPath();
            if (path != null) {

                int len = path.length();
                for (int i = 0; i < len; i++) {

                    if ("?<>:*|\"".indexOf(path.charAt(i)) > -1)
                        return false;
                }
            }
        }

        return true;
    } catch (Exception ex) {

        return false;
    }
}

From source file:Main.java

public static String convertUtc2LocalPro(String utcTime) {
    if (TextUtils.isEmpty(utcTime)) {
        return "";
    }//from   ww  w .  j  a  v  a  2s  . c  om
    // 2014-10-24T02:58:05.932Z
    SimpleDateFormat utcFormatter, localFormatter;
    utcFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);
    Date date;
    Calendar cal = Calendar.getInstance();
    try {
        date = utcFormatter.parse(utcTime);
        cal.setTime(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    cal.add(Calendar.HOUR_OF_DAY, +8);
    date = cal.getTime();
    localFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
    return localFormatter.format(date);
}

From source file:Main.java

public static String getGMTDate(Date date) {
    if (date == null) {
        return null;
    }//from  ww  w.  j  a v  a  2  s  . c  om
    DateFormat dateFormat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    String dateStr = dateFormat.format(date);
    return dateStr;
}