How to control the capitalization of month and day names returned by DateFormat?(如何控制 DateFormat 返回的月份和日期名称的大小写?)
问题描述
这是一个快速测试程序:
Here is a quick test program:
public static void main( String[] args )
{
Date date = Calendar.getInstance().getTime();
System.out.println("Months:");
printDate( "MMMM", "en", date );
printDate( "MMMM", "es", date );
printDate( "MMMM", "fr", date );
printDate( "MMMM", "de", date );
System.out.println("Days:");
printDate( "EEEE", "en", date );
printDate( "EEEE", "es", date );
printDate( "EEEE", "fr", date );
printDate( "EEEE", "de", date );
}
public static void printDate( String format, String locale, Date date )
{
System.out.println( locale + ": " + (new SimpleDateFormat( format, new Locale( locale ) )).format( date ) );
}
输出是:
<代码>月份:zh: 九月es: 九月法国:九月去:九月天:zh: 星期一es: 月牙fr: 隆迪de: 蒙塔格
如何控制名称的大小写.出于某种原因,西班牙语和法语似乎总是返回以小写字母开头的名称.
How can I control the capitalization of the names. For some reason the Spanish and French always seem to return names that start with a lowercase letter.
推荐答案
并非所有语言都共享英文大写规则.我猜您需要更改 API 使用的数据,但您的非英语客户可能不喜欢它...
Not all languages share english capitalization rules. I guess you'd need to alter the data used by the API, but your non-english clients might not appreciate it...
about.com 关于法语大写
这篇关于如何控制 DateFormat 返回的月份和日期名称的大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何控制 DateFormat 返回的月份和日期名称的大小写?
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01