本文整理汇总了Java中java.util.Locale.SIMPLIFIED_CHINESE属性的典型用法代码示例。如果您正苦于以下问题:Java Locale.SIMPLIFIED_CHINESE属性的具体用法?Java Locale.SIMPLIFIED_CHINESE怎么用?Java Locale.SIMPLIFIED_CHINESE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.Locale
的用法示例。
在下文中一共展示了Locale.SIMPLIFIED_CHINESE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeLanguage
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);
}
示例2: getLocale
/**
* <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;
}
示例3: checkLanguage
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);
}
}
示例4: invoke
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();
}
示例5: getLocale
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();
}
示例6: getLanguageLocale
/**
* 如果不是英文、简体中文、繁体中文,默认返回简体中文
*
* @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;
}
示例7: computePastTime
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;
}
示例8: init
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";
}
示例9: getLocale
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();
}
示例10: showLanguage
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();
}
示例11: str2Date
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();
}
示例12: date2Str
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;
}
示例13: getLocale
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);
}