问题标题中指定的方法中 Locale 的作用是什么?它如何影响任何结果?我正在尝试以下两行代码:
Calendar cal = Calendar.getInstance();
System.out.println(cal.getTime().toString());
即使我使用参数 Locale.GERMANY 或 Locale.ITALY 尝试,我也会收到相同的结果。什么时候它会真正影响结果?
最佳答案
当您执行诸如一周第一天等调用时,它会很有用,当您执行 getTime()
时,您可能看不到任何差异。
根据 javadoc
Calendar defines a locale-specific seven day week using two parameters: the first day of the week and the minimal days in first week (from 1 to 7). These numbers are taken from the locale resource data when a Calendar is constructed.
关于java - 方法 Calendal.getInstance(Locale aLocale) 中的区域设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14103593/