Example usage for java.util Locale SIMPLIFIED_CHINESE

List of usage examples for java.util Locale SIMPLIFIED_CHINESE

Introduction

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

Prototype

Locale SIMPLIFIED_CHINESE

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

Click Source Link

Document

Useful constant for language.

Usage

From source file:Main.java

public static void main(String[] args) {
    Locale locale = Locale.SIMPLIFIED_CHINESE;

    System.out.println("Locale1:" + locale);

    // print the country of this locale
    System.out.println("Country:" + locale.getCountry());

}

From source file:Main.java

public static String getTime() {
    SimpleDateFormat format = new SimpleDateFormat("HH:mm", Locale.SIMPLIFIED_CHINESE);
    return format.format(new Date());
}

From source file:Main.java

public static String getTimes() {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
    return format.format(new Date());
}

From source file:Main.java

public static String parseDateToStr(Date date, String fmt) {
    DateFormat dateFormat = new SimpleDateFormat(fmt, Locale.SIMPLIFIED_CHINESE);
    return dateFormat.format(date);
}

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:/*  www  . 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 isYesterday(String dateStr) {
    long curTime = System.currentTimeMillis();
    long yesTime = curTime - 24 * 60 * 60 * 1000;
    Date date = new Date(yesTime);
    SimpleDateFormat dateFormate = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
    String str = dateFormate.format(date);
    if (!isEmpty(dateStr) && dateStr.equals(str)) {
        return true;
    }//from  w ww. jav  a 2 s .  c o  m
    return false;
}

From source file:Main.java

public static String getFormatDate(final Date date, String type) {
    if (null == date || TextUtils.isEmpty(type)) {
        return null;
    }//from w w  w . ja  v a  2  s . c o m

    SimpleDateFormat sdf;
    try {
        sdf = new SimpleDateFormat(type, Locale.SIMPLIFIED_CHINESE);
    } catch (Exception e) {
        sdf = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
    }
    TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
    sdf.setTimeZone(timeZone);
    return sdf.format(date);
}

From source file:Main.java

public static void changeAppLanguage(Resources resources, String lanAtr) {
    Configuration config = resources.getConfiguration();
    DisplayMetrics dm = resources.getDisplayMetrics();
    if (lanAtr.equals("zh-cn")) {
        config.locale = Locale.SIMPLIFIED_CHINESE;
    } else {/* w ww.  j  a  v  a 2  s  .  c  om*/
        config.locale = Locale.getDefault();
    }
    resources.updateConfiguration(config, dm);
}

From source file:Main.java

public static void setLocale(String lang, Resources res) {
    Locale myLocale;//ww  w.  j a  va  2 s. c o  m
    if (lang.equalsIgnoreCase("zh-rTW")) {
        myLocale = Locale.TRADITIONAL_CHINESE;
    } else if (lang.equalsIgnoreCase("zh-rCN") || lang.equalsIgnoreCase("zh")) {
        myLocale = Locale.SIMPLIFIED_CHINESE;
    } else if (lang.equalsIgnoreCase("pt-rBR") || lang.equalsIgnoreCase("pt")) {
        myLocale = new Locale("pt", "BR");
    } else if (lang.equalsIgnoreCase("pt-rPT")) {
        myLocale = new Locale("pt", "PT");
    } else {
        myLocale = new Locale(lang);
    }
    DisplayMetrics dm = res.getDisplayMetrics();
    Configuration conf = res.getConfiguration();
    conf.locale = myLocale;
    res.updateConfiguration(conf, dm);
}

From source file:com.sinpo.xnfc.nfc.Util.java

public static String getTime() {
    Date date = new Date();
    SimpleDateFormat dateFormat = new SimpleDateFormat("", Locale.SIMPLIFIED_CHINESE);
    dateFormat.applyPattern("yyyy");
    dateFormat.applyPattern("MM");
    dateFormat.applyPattern("dd");
    dateFormat.applyPattern("[yyyy-MM-dd HH:mm:ss]");
    String time = dateFormat.format(date);
    return time;//from w ww .ja va2s.c  o m
}