如何动态地将Date转换成乌克兰语。
我用的是这个代码:
final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM, yyyy");
final Date date = calendar.getTime();
final TextView chosenMonth = (TextView) findViewById(R.id.chosenMonth);
chosenMonth.setText(dateFormat.format(date));将日期格式为“2013年9月”。这个文本语言是设备语言,但是我需要格式化这个日期,并且只用乌克兰语言显示。
我尝试使用Locale类来实现这一点,但是UA语言没有常量。
发布于 2013-09-02 18:26:48
尽管没有常量,但如果设备上支持它,则仍然可以自行设置区域设置。Refer to this list of supported locales by Android version。
使用new Locale('uk','UA')创建您的Ukranian语言环境,然后在接受区域设置的SimpleDateFormat版本中使用它。
这个能行吗?
final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM, yyyy", new Locale('uk','UA'));发布于 2013-09-02 18:22:58
尝试使用DateFormat.getDateInstance(int style, Locale locale),而不是用SimpleDateFormat创建自己的模式。
https://stackoverflow.com/questions/18578882
复制相似问题