Search code examples
javacalendarlocale

Locale in method Calendal.getInstance(Locale aLocale)


What is the role of Locale in the method specified in question title? How does it affect any results? I am trying the following two lines of code:

Calendar cal = Calendar.getInstance();
System.out.println(cal.getTime().toString());

I receive the same result even if I try it with the parameter Locale.GERMANY or Locale.ITALY. When does it affect actually the result?


Solution

  • It will be useful when you do calls like first day of week etc., when you do getTime() you may not see any difference.

    As per 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.