alwbtc alwbtc - 3 months ago 15
Java Question

How to set first day of week in a Java application calendar

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?

Regards

Answer

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

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:

  • 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.