How to specify firstDayOfWeek for java.util.Calendar using a JVM argument

Question:

 

     I'm trying to change default firstDayOfWeek for java.util.Calendar from SUNDAY to MONDAY. Is it possible to achieve this through JVM configuration instead of adding this piece of code?

 

cal.setFirstDayOfWeek(Calendar.MONDAY); 

 

Answer:

   

    The first day of the week is derived from the current locale. If you don't set the locale of the calendar (Calendar.getInstance(Locale), or new GregorianCalendar(Locale)), it will use the system's default. The system's default can be overridden by a JVM parameter:

 

    This should show a different output with different JVM parameters for language/country:

 

-Duser.language=en -Duser.country=US -> en_US: 1 (Sunday)
-Duser.language=en -Duser.country=GB -> en_GB: 2 (Monday)

 

 

你可能感兴趣的:(java,jvm)