Java Code Examples for java.util.Locale#CHINA
The following examples show how to use
java.util.Locale#CHINA .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Gojuon.java From Gojuon with MIT License | 6 votes |
public void setLanguage() { String language = getSharedPreferences().getString(KEY_LANGUAGE, LANGUAGE_AUTO); Configuration configuration = getResources().getConfiguration(); switch (language) { case LANGUAGE_AUTO: configuration.locale = Locale.getDefault(); break; case LANGUAGE_ENGLISH: configuration.locale = Locale.ENGLISH; break; case LANGUAGE_CHINESE: configuration.locale = Locale.CHINA; break; } getBaseContext().getResources().updateConfiguration(configuration, null); }
Example 2
Source File: AboutActivity.java From v9porn with MIT License | 6 votes |
@SuppressLint("SetTextI18n") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); ButterKnife.bind(this); initToolBar(toolbar); initAboutSection(); mVersionTextView.setText("v" + QMUIPackageHelper.getAppVersion(this)); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy", Locale.CHINA); String currentYear = dateFormat.format(new java.util.Date()); mCopyrightTextView.setText(String.format(getResources().getString(R.string.about_copyright), currentYear)); alertDialog = DialogUtils.initLoadingDialog(this, "正在检查更新,请稍后..."); presenter.countCacheFileSize(getString(R.string.about_item_clean_cache)); }
Example 3
Source File: ResourcesTest.java From dolphin with Apache License 2.0 | 5 votes |
@Test public void testXmlCopyrightReading() { Resources resources = new Resources(CommentGenerator.XMBG_CG_I18N_DEFAULT_PATH + "/Copyrights", Locale.CHINA); String copyright = resources.getFormatted("XmlSource", "2012", "2015"); if (StringUtils.isEmpty(copyright)) return; String[] array = copyright.split("\\|"); for (String str : array) { if (!str.startsWith("<!--") && !str.startsWith("-->")) { str = " " + str; } System.out.println(str); } }
Example 4
Source File: DateUtil.java From Sunshine with Apache License 2.0 | 5 votes |
/** * 从字符串中获取月份【字符串形式类似2017-09-29 xx(后面无所谓)】 * * @param dataStr 日期时间字符串 * @return 月份(1月就是1,0代表解析错误的月份) */ public static int getMonthFromString(String dataStr) { Calendar calendar = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); try { Date date = df.parse(dataStr); calendar.setTime(date); return calendar.get(Calendar.MONTH) + 1; } catch (ParseException e) { e.printStackTrace(); return 0; } }
Example 5
Source File: DateUtil.java From kAndroid with Apache License 2.0 | 5 votes |
/** * * @param dateString * @return */ public static Date getDateByByStringDate(String dateString) { if (TextUtils.isEmpty(dateString)) { return null; } DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.CHINA); Date date = null; try { date = sdf.parse(dateString); } catch (ParseException e) { } return date; }
Example 6
Source File: AbstractAPI.java From JAVA-HTTP-SDK with MIT License | 5 votes |
private ObjectMapper initObjectMapper() { ObjectMapper objectMapper = new ObjectMapper(); //关闭字段不识别报错 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //调整默认时区为北京时间 TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); dateFormat.setTimeZone(timeZone); objectMapper.setDateFormat(dateFormat); objectMapper.setTimeZone(timeZone); return objectMapper; }
Example 7
Source File: HybridCacheUtils.java From AndroidHybridLib with Apache License 2.0 | 5 votes |
/** * 根据系统时间、前缀、后缀产生一个文件 */ public static File createFile(File folder, String prefix, String suffix) { if (!folder.exists() || !folder.isDirectory()) folder.mkdirs(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA); String filename = prefix + dateFormat.format(new Date(System.currentTimeMillis())) + suffix; return new File(folder, filename); }
Example 8
Source File: Util.java From BaseProject with Apache License 2.0 | 5 votes |
/** * 调试追踪信息,记录到本地文件 注:正式发版时将变量CommonConfigs.DEBUG_TRACE_FLAG 置为false; * @param mContext * @param message */ public static synchronized void debugTraceLog(Context mContext, String message) { if (!CommonConfigs.DEBUG_TRACE_FLAG) { return; } if (mContext == null) { mContext = NetHelper.getAppContext(); } SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); String oneDayAsFileName = dateFormat.format(new Date()); File logFile = StorageUtil.getFileInCache(mContext, CommonConfigs.DEBUG_TRACE_DIR_NAME + mContext.getPackageName() + // CommonConfigs.DEBUG_TRACE_FILE_NAME "/"+ //changed : 以天为文件名 oneDayAsFileName ); if (!logFile.exists()) { return; } try { PrintWriter pw = new PrintWriter(new FileWriter(logFile, true)); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); Date now = new Date(); String dateInfo = sdf.format(now) + " --- "; pw.println(dateInfo + message); pw.flush(); pw.close(); } catch (Exception e) { CommonLog.e("info", e); } }
Example 9
Source File: ImageUtils.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 根据系统时间、前缀、后缀产生一个文件 */ public static File createFile(File folder, String prefix, String suffix) { if (!folder.exists() || !folder.isDirectory()) folder.mkdirs(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.CHINA); String filename = prefix + dateFormat.format(new Date(System.currentTimeMillis())) + suffix; return new File(folder, filename); }
Example 10
Source File: Helper.java From Medusa with Apache License 2.0 | 5 votes |
public static final DateTimeFormatter getDateFormat(final Locale LOCALE) { if (Locale.US == LOCALE) { return DateTimeFormatter.ofPattern("MM/dd/YYYY"); } else if (Locale.CHINA == LOCALE) { return DateTimeFormatter.ofPattern("YYYY.MM.dd"); } else { return DateTimeFormatter.ofPattern("dd.MM.YYYY"); } }
Example 11
Source File: SES_SignatureTest.java From ofdrw with Apache License 2.0 | 5 votes |
@Test void build() throws Exception { Path p = Paths.get("src/test/resources", "UserV1.esl"); final Path out = Paths.get("target/SignedValue.dat"); Path userP12 = Paths.get("src/test/resources", "USER.p12"); Certificate userCert = PKCS12Tools.ReadUserCert(userP12, "private", "777777"); byte[] mockDigest = new byte[32]; SESeal seal = SESeal.getInstance(Files.readAllBytes(p)); String propertyInfo = "/Doc_0/Signs/Signatures.xml"; ASN1UTCTime signUTCTime = new ASN1UTCTime(new Date(), Locale.CHINA); TBS_Sign tbsSign = new TBS_Sign() .setVersion(new ASN1Integer(1)) .setEseal(seal) .setTimeInfo(new DERBitString(signUTCTime)) .setDataHash(new DERBitString(mockDigest)) .setPropertyInfo(new DERIA5String(propertyInfo)) .setCert(new DEROctetString(userCert.getEncoded())) .setSignatureAlgorithm(GMObjectIdentifiers.sm2sign_with_sm3); char[] pwd = "777777".toCharArray(); KeyStore userKs = KeyStore.getInstance("PKCS12", new BouncyCastleProvider()); try (InputStream rootKsIn = Files.newInputStream(userP12)) { userKs.load(rootKsIn, pwd); // 取得印章制作者证书的私钥 PrivateKey privateKey = (PrivateKey) userKs.getKey("private", pwd); Signature signature = Signature.getInstance("SM3withSm2", "BC"); signature.initSign(privateKey); signature.update(tbsSign.getEncoded("DER")); byte[] sign = signature.sign(); SES_Signature sesSignature = new SES_Signature(tbsSign, new DERBitString(sign)); Files.write(out, sesSignature.getEncoded("DER")); } }
Example 12
Source File: DateUtil.java From myapplication with Apache License 2.0 | 5 votes |
/** * @param datePattenStr 日期格式 * @return 日期字符串 */ public static String getCurrentTimeStr(String datePattenStr) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(datePattenStr, Locale.CHINA); Date date = new Date(System.currentTimeMillis()); return simpleDateFormat.format(date); }
Example 13
Source File: Helper.java From tilesfx with Apache License 2.0 | 5 votes |
public static final DateTimeFormatter getDateFormat(final Locale LOCALE) { if (Locale.US == LOCALE) { return DateTimeFormatter.ofPattern("MM/dd/YYYY"); } else if (Locale.CHINA == LOCALE) { return DateTimeFormatter.ofPattern("YYYY.MM.dd"); } else { return DateTimeFormatter.ofPattern("dd.MM.getY()YYY"); } }
Example 14
Source File: AboutActivity.java From PoetryWeather with Apache License 2.0 | 5 votes |
private void initAboutList() { //初始化LOGO下面的名称和版本号 mVersionTextView.setText("诗语天气 V1.0.2"); //作者 QMUICommonListItemView itemAuthor = mAboutGroupListView.createItemView("作者"); itemAuthor.setDetailText("黄振敏"); //微信 QMUICommonListItemView itemWechat = mAboutGroupListView.createItemView("微信"); itemWechat.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON); itemWechat.setDetailText("hzm1998hzm"); itemWechat.setTag(R.id.listitem_tag_1); //QQ QMUICommonListItemView itemQQ = mAboutGroupListView.createItemView("QQ"); itemQQ.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON); itemQQ.setDetailText("934585316"); itemQQ.setTag(R.id.listitem_tag_2); //GitHub主页 QMUICommonListItemView itemGitHub = mAboutGroupListView.createItemView("作者GitHub主页"); itemGitHub.setOrientation(QMUICommonListItemView.VERTICAL); itemGitHub.setDetailText("https://github.com/hzm0321"); itemGitHub.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON); itemGitHub.setTag(R.id.listitem_tag_3); QMUIGroupListView.newSection(this) .setDescription(getString(R.string.about_description)) .addItemView(itemAuthor, null) .addItemView(itemWechat, mOnClickListenerListItem) .addItemView(itemQQ, mOnClickListenerListItem) .addItemView(itemGitHub, mOnClickListenerListItem) .addTo(mAboutGroupListView); //初始化页面底部的版权 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy", Locale.CHINA); String currentYear = dateFormat.format(new java.util.Date()); mCopyrightTextView.setText(String.format(getResources().getString(R.string.about_copyright), currentYear)); }
Example 15
Source File: TextUtils.java From wES with MIT License | 5 votes |
public static Date parseDate(String date, String format) { if (date == null) { return null; } SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format, Locale.CHINA); try { return simpleDateFormat.parse(date + ""); } catch (ParseException e) { return null; } }
Example 16
Source File: WrapLocale.java From jphp with Apache License 2.0 | 4 votes |
@Signature public static Memory CHINA(Environment env, Memory... args) { return new ObjectMemory(new WrapLocale(env, Locale.CHINA)); }
Example 17
Source File: TimeUtils.java From HeartBeat with Apache License 2.0 | 4 votes |
public static String timeFormat(long timeMillis, String pattern){ SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.CHINA); return format.format(new Date(timeMillis)); }
Example 18
Source File: MainActivity.java From MapForTour with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SDKInitializer.initialize(getApplicationContext()); setContentView(R.layout.activity_main); application = (DeviceMessageApplication) getApplication(); //设置广播接收器 mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("cc.bitlight.broadcast.location.data"); intentFilter.addAction("cc.bitlight.broadcast.nearbyinfo.data"); intentFilter.addAction("cc.bitlight.broadcast.track.historytrack.draw"); intentFilter.addAction("cc.bitlight.broadcast.geofence.reload"); intentFilter.addAction("cc.bitlight.broadcast.geofence.notification"); locationReceiver = new MainBroadCastReceiver(); mLocalBroadcastManager.registerReceiver(locationReceiver, intentFilter); coordinatorLayoutContainer = (CoordinatorLayout) findViewById(R.id.coordinatorLayoutContainer); //界面UI布局 setToolbarDrawerLayout(); setTabLayout(); //时间格式化 simpleDateFormatDate = new SimpleDateFormat("yyyy-M-d H:mm", Locale.CHINA); calendar = Calendar.getInstance(); //启动服务 startService = new Intent(this, MapService.class); startService(startService); //界面UI刷新 handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case MESSAGE_LOGIN_SUCCEED: optionMapFragment.setLoginSucceed(); break; case UPDATE_NAVIGATIONVIEW_TIME_START: navigationViewItemTimeStart.setTitle("起始:" + simpleDateFormatDate.format(application.getdateStartTime())); break; case UPDATE_NAVIGATIONVIEW_TIME_END: navigationViewItemTimeEnd.setTitle("截止:" + simpleDateFormatDate.format(application.getdateEndTime())); Log.d("lml", "application.getMillisecondStartTime():" + (int) (application.getMillisecondStartTime() / 1000)); Log.d("lml", "application.getMillisecondEndTime():" + (int) (application.getMillisecondEndTime() / 1000)); Log.d("lml", "System.currentTimeMillis():" + (int) (System.currentTimeMillis() / 1000)); break; } } }; }
Example 19
Source File: ReadLaterAdapter.java From WanAndroid with Apache License 2.0 | 4 votes |
public ReadLaterAdapter(Context context, List<ReadLaterArticleData> list){ this.context = context; inflater = LayoutInflater.from(this.context); mList = list; simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA); }
Example 20
Source File: DateUtils.java From AccountBook with GNU General Public License v3.0 | 2 votes |
/** * 将日期对象,格式化为指定日期格式的日期字符串。 * @param c 日期对象 * @param format 日期格式 * @return 根据指定日期格式格式话后的字符串,如:2017-04-07 */ public static String getDateText(Calendar c, String format){ SimpleDateFormat f = new SimpleDateFormat(format != null ? format : FORMAT, Locale.CHINA); return f.format(c.getTime()); }