如何在 Java 应用程序日历中设置一周的第一天

2022-01-11 00:00:00 windows calendar java weekday

我们使用一个 java 应用程序,它有一个日期选择字段,当您单击该字段时,会打开一个小日历.一周的第一天是星期天.但我希望它是星期一.我尝试从日期设置中的 Windows 控制面板更改它.例如,我将 Windows 日历的第一天设置为星期四.但是在 Java 应用程序的日历中,一周的第一天仍然是星期日.是否可以从 Windows 更改 Java 应用程序的一周的第一天,还是仅从 Java 应用程序的代码更改?

We use a java application, it has a date selection field, when you click there a small calendar opens. First day of the week is Sunday there. But I want it to be Monday. I try to change it from Windows Control Panel from Date settings. I set Windows calendar's first day to Thursday, for instance. But in Java application's calendar, first day of the week is still Sunday. Is it possible to change the Java application's first day of the week from Windows, or is it only changed from Java application's code?

问候

推荐答案

您的 java 应用使用哪个框架?日期选择字段是什么组件?

Which framework does your java app use? What kind of component is the date selection field?

在 Java 的 Calendar 中,默认情况下一周的第一天由系统的区域设置决定.

In Java's Calendar the first day of week by default is determined by the Locale setting of your system.

因此,如果您无法更改应用程序的源代码:

So if you cannot change the source code of your application:

  • 您可能想要更改操作系统的区域设置(在您的情况下为 Windows)
  • 或者您可以在启动 jvm 时使用各种命令行参数,例如 -Duser.country-Duser.region for java.看看这里.
  • you might want to change the locale of your operating system (in your case Windows)
  • or you might use various command line arguments like -Duser.country or -Duser.region for java when firing up your jvm. Have a look here.

相关文章