Java Code Examples for java.util.Locale.SIMPLIFIED_CHINESE

The following are Jave code examples for showing how to use SIMPLIFIED_CHINESE of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: HLOLI   File: App.java   View Source Code Vote up 6 votes
public static void changeLanguage(Context context) {
    Resources resources = context.getResources();
    DisplayMetrics dm = resources.getDisplayMetrics();
    Configuration config = resources.getConfiguration();
    switch (SharedPreManager.getInstance().getLanguage(context)) {
        case Constant.LANGUAGE_CHINA:
            config.locale = Locale.SIMPLIFIED_CHINESE;
            break;
        case Constant.LANGUAGE_ENGLISH:
            config.locale = Locale.ENGLISH;
            break;
        case Constant.LANGUAGE_DEFAULT:
            config.locale = Locale.getDefault();
            break;
    }
    // 应用用户选择语言
    resources.updateConfiguration(config, dm);
}
 
Example 2
Project: database-transform-tool   File: ResourceHolder.java   View Source Code Vote up 6 votes
/**
 * <pre>
 * 描述:获取本地语言
 * 作者:ZhangYi
 * 时间:2015年1月30日 下午1:24:06
 * 参数:(参数列表)
 * @param language
 * @return
 * </pre>
 */
public static Locale getLocale(String language) {
	Locale locale = Locale.CHINESE;
	if (!StringUtil.isEmpty(language)) {
		language = language.toLowerCase();
		if (language.indexOf("en") != -1) {
			locale = Locale.ENGLISH;
		}
		if (language.indexOf("zh_hk") != -1) {
			locale = Locale.TRADITIONAL_CHINESE;
		}
		if (language.indexOf("zh_cn") != -1) {
			locale = Locale.SIMPLIFIED_CHINESE;
		}
	}
	return locale;
}
 
Example 3
Project: Lamp   File: WifiConnectActivity.java   View Source Code Vote up 6 votes
private void checkLanguage() {

        SharedPreferences sharedPreferences = this.getSharedPreferences("set", MODE_PRIVATE);
        /**
         * 获取系统配置
         */
        Resources resources = getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        Configuration config = resources.getConfiguration();


        if (LANGUAGE_CN.equals(sharedPreferences.getString("language", "0"))) {

            config.locale = Locale.SIMPLIFIED_CHINESE;
            resources.updateConfiguration(config, dm);
        } else if (LANGUAGE_EN.equals(sharedPreferences.getString("language", "0"))) {

            config.locale = Locale.ENGLISH;
            resources.updateConfiguration(config, dm);
        } else {

            config.locale = Locale.SIMPLIFIED_CHINESE;
            resources.updateConfiguration(config, dm);
        }

    }
 
Example 4
Project: Limitart   File: TimeUtil.java   View Source Code Vote up 5 votes
public static long str2Date(String str) {
	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
	Date parse = null;
	try {
		parse = format.parse(str);
	} catch (ParseException e) {
		log.error("parse error", e);
		return 0;
	}
	return parse.getTime();
}
 
Example 5
Project: EatDubbo   File: LocaleValve.java   View Source Code Vote up 5 votes
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example 6
Project: EatDubbo   File: LocaleUtils.java   View Source Code Vote up 5 votes
public static Locale getLocale(String language) {
	if ("en".equalsIgnoreCase(language)) {
    	return Locale.ENGLISH;
    } else if ("zh".equalsIgnoreCase(language)) {
    	return Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equalsIgnoreCase(language)) {
    	return Locale.TRADITIONAL_CHINESE;
    }
    return Locale.getDefault();
}
 
Example 7
Project: dubbo2   File: LocaleValve.java   View Source Code Vote up 5 votes
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example 8
Project: dubbo2   File: LocaleUtils.java   View Source Code Vote up 5 votes
public static Locale getLocale(String language) {
	if ("en".equalsIgnoreCase(language)) {
    	return Locale.ENGLISH;
    } else if ("zh".equalsIgnoreCase(language)) {
    	return Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equalsIgnoreCase(language)) {
    	return Locale.TRADITIONAL_CHINESE;
    }
    return Locale.getDefault();
}
 
Example 9
Project: AndroidMultiLanguage   File: MultiLanguageUtil.java   View Source Code Vote up 5 votes
/**
 * 如果不是英文、简体中文、繁体中文,默认返回简体中文
 *
 * @return
 */
private Locale getLanguageLocale() {
    int languageType = CommSharedUtil.getInstance(mContext).getInt(MultiLanguageUtil.SAVE_LANGUAGE, 0);
    if (languageType == LanguageType.LANGUAGE_FOLLOW_SYSTEM) {
        Locale sysType = getSysLocale();
        if (sysType.equals(Locale.ENGLISH)) {
            return Locale.ENGLISH;
        } else if (sysType.equals(Locale.TRADITIONAL_CHINESE)) {
            return Locale.TRADITIONAL_CHINESE;
        } else if (TextUtils.equals(sysType.getLanguage(), Locale.CHINA.getLanguage())) { //zh
            if (TextUtils.equals(sysType.getCountry(), Locale.CHINA.getCountry())) {  //适配华为mate9  zh_CN_#Hans
                return Locale.SIMPLIFIED_CHINESE;
            }
        } else {
            return Locale.SIMPLIFIED_CHINESE;
        }
    } else if (languageType == LanguageType.LANGUAGE_EN) {
        return Locale.ENGLISH;
    } else if (languageType == LanguageType.LANGUAGE_CHINESE_SIMPLIFIED) {
        return Locale.SIMPLIFIED_CHINESE;
    } else if (languageType == LanguageType.LANGUAGE_CHINESE_TRADITIONAL) {
        return Locale.TRADITIONAL_CHINESE;
    }
    Log.e(TAG, "getLanguageLocale" + languageType + languageType);
    getSystemLanguage(getSysLocale());
    return Locale.SIMPLIFIED_CHINESE;
}
 
Example 10
Project: diycode   File: TimeUtil.java   View Source Code Vote up 5 votes
public static String computePastTime(String time) {
    // Log.v(TAG, "computePastTime: " + time);
    String result = "刚刚";
    //2017-02-13T01:20:13.035+08:00
    time = time.replace("T", " ");
    time = time.substring(0, 22);
    // Log.v(TAG, "computePastTime time: " + time);
    SimpleDateFormat simpleDateFormat =
            new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.SIMPLIFIED_CHINESE);
    try {
        Date t = simpleDateFormat.parse(time);
        Date now = new Date(System.currentTimeMillis());
        long diff = (now.getTime() - t.getTime()) / 1000;
        if (diff < 60) {
            result = "刚刚";
        } else if ((diff /= 60) < 60) {
            result = diff + "分钟前";
        } else if ((diff /= 60) < 24) {
            result = diff + "小时前";
        } else if ((diff /= 24) < 30) {
            result = diff + "天前";
        } else if ((diff /= 30) < 12) {
            result = diff + "月前";
        } else {
            diff /= 12;
            result = diff + "年前";
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
    // Log.v(TAG, "computePastTime result: " + result);
    return result;
}
 
Example 11
Project: PDR   File: PDRService.java   View Source Code Vote up 5 votes
public void init() {
  	//��ʼ��������ͼƲ���
  	mOrientation = new GyroscopeOrientation(this);
  	mStepDetector = new StepDetector(this);
  	//���ó�ʼ���λ����Ϣ��
  	mPosition[0] = 3;
  	mPosition[1] = 5;
  	mPositionEstimate = new PositionEstimate(mPosition, 0);
  	//���ü�¼txt�ļ���fileName��
  	SimpleDateFormat sdf = new SimpleDateFormat("MMdd.HHmm.ss",Locale.SIMPLIFIED_CHINESE);
String timeStr = sdf.format(new Date());
fileName = mOutputSdCard.getSDPath() + "/"  + timeStr + ".txt";
  }
 
Example 12
Project: github-test   File: LocaleValve.java   View Source Code Vote up 5 votes
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example 13
Project: github-test   File: LocaleUtils.java   View Source Code Vote up 5 votes
public static Locale getLocale(String language) {
    if ("en".equalsIgnoreCase(language)) {
        return Locale.ENGLISH;
    } else if ("zh".equalsIgnoreCase(language)) {
        return Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equalsIgnoreCase(language)) {
        return Locale.TRADITIONAL_CHINESE;
    }
    return Locale.getDefault();
}
 
Example 14
Project: MegviiFacepp-Android-SDK   File: LoadingActivity.java   View Source Code Vote up 5 votes
protected void showLanguage(String language) {
        //设置应用语言类
        Resources resources = getResources();
        Configuration config = resources.getConfiguration();
        DisplayMetrics dm = resources.getDisplayMetrics();
        if (language.equals("zh")) {
            config.locale = Locale.SIMPLIFIED_CHINESE;
        } else {
            config.locale = Locale.ENGLISH;
        }
        resources.updateConfiguration(config, dm);
        mSharedUtil.saveStringValue("language", language);
//        freshView();
    }
 
Example 15
Project: dubbox-hystrix   File: LocaleValve.java   View Source Code Vote up 5 votes
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example 16
Project: dubbox-hystrix   File: LocaleUtils.java   View Source Code Vote up 5 votes
public static Locale getLocale(String language) {
	if ("en".equalsIgnoreCase(language)) {
    	return Locale.ENGLISH;
    } else if ("zh".equalsIgnoreCase(language)) {
    	return Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equalsIgnoreCase(language)) {
    	return Locale.TRADITIONAL_CHINESE;
    }
    return Locale.getDefault();
}
 
Example 17
Project: dubbocloud   File: LocaleValve.java   View Source Code Vote up 5 votes
public void invoke(PipelineContext pipelineContext) throws Exception {
    TurbineRunData rundata = getTurbineRunData(request);
    if (ignoreTarget(rundata.getTarget())) {
        pipelineContext.invokeNext();
        return;
    }

    //默认是中文
    String[] temp = rundata.getCookies().getStrings("locale");
    String locale = null;
    if (temp != null) {
        if (temp.length > 1) {
            locale = temp[temp.length - 1];
        } else if (temp.length == 1) {
            locale = temp[0];
        }
    }
    if (locale == null || "".equals(locale)) {
        locale = "zh";
    }

    Locale newLocale = Locale.SIMPLIFIED_CHINESE;
    if ("en".equals(locale)) {
        newLocale = Locale.ENGLISH;
    } else if ("zh".equals(locale)) {
        newLocale = Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equals(locale)) {
        newLocale = Locale.TRADITIONAL_CHINESE;
    }
    LocaleUtil.setLocale(newLocale);

    pipelineContext.invokeNext();
}
 
Example 18
Project: dubbocloud   File: LocaleUtils.java   View Source Code Vote up 5 votes
public static Locale getLocale(String language) {
	if ("en".equalsIgnoreCase(language)) {
    	return Locale.ENGLISH;
    } else if ("zh".equalsIgnoreCase(language)) {
    	return Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equalsIgnoreCase(language)) {
    	return Locale.TRADITIONAL_CHINESE;
    }
    return Locale.getDefault();
}
 
Example 19
Project: Limitart   File: TimeUtil.java   View Source Code Vote up 4 votes
public static String date2Str(long date) {
	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
	Date temp = new Date(date);
	String format2 = format.format(temp);
	return format2;
}
 
Example 20
Project: openjdk-jdk10   File: MessageCatalog.java   View Source Code Vote up 4 votes
private Locale getLocale(String localeName) {
    String language, country;
    int index;

    index = localeName.indexOf('_');
    if (index == -1) {
        //
        // Special case the builtin JDK languages
        //
        if (localeName.equals("de"))
            return Locale.GERMAN;
        if (localeName.equals("en"))
            return Locale.ENGLISH;
        if (localeName.equals("fr"))
            return Locale.FRENCH;
        if (localeName.equals("it"))
            return Locale.ITALIAN;
        if (localeName.equals("ja"))
            return Locale.JAPANESE;
        if (localeName.equals("ko"))
            return Locale.KOREAN;
        if (localeName.equals("zh"))
            return Locale.CHINESE;

        language = localeName;
        country = "";
    } else {
        if (localeName.equals("zh_CN"))
            return Locale.SIMPLIFIED_CHINESE;
        if (localeName.equals("zh_TW"))
            return Locale.TRADITIONAL_CHINESE;

        //
        // JDK also has constants for countries:  en_GB, en_US, en_CA,
        // fr_FR, fr_CA, de_DE, ja_JP, ko_KR.  We don't use those.
        //
        language = localeName.substring(0, index);
        country = localeName.substring(index + 1);
    }

    return new Locale(language, country);
}