public void setLocale ( Locale locale ) { // Check for null, which indicates that we should use the default locale. if ( locale == null ) { locale = Locale . getDefault ( ) ; } // Fix a problem where the Hindi locale is not recognized by language alone. if ( "hi" . equals ( locale . getLanguage ( ) ) && ( locale . getCountry ( ) . isEmpty ( ) ) ) { locale = new Locale ( "hi" , "IN" ) ; } this . locale = locale ; // Do not redraw the calendar until this function is complete. zSkipDrawIndependentCalendarPanelIfNeeded = true ; // Set the default week number rules. WeekFields localeWeekFields = WeekFields . of ( locale ) ; setWeekNumberRules ( localeWeekFields ) ; // Set the default "today" and "clear" translations for the locale. String todayTranslation = TranslationSource . getTranslation ( locale , "today" , "Today" ) ; setTranslationToday ( todayTranslation ) ; String clearTranslation = TranslationSource . getTranslation ( locale , "clear" , "Clear" ) ; setTranslationClear ( clearTranslation ) ; // Set the default standalone month names for the locale. String [ ] standaloneLongMonthNames = ExtraDateStrings . getDefaultStandaloneLongMonthNamesForLocale ( locale ) ; setTranslationArrayStandaloneLongMonthNames ( standaloneLongMonthNames ) ; String [ ] standaloneShortMonthNames = ExtraDateStrings . getDefaultStandaloneShortMonthNamesForLocale ( locale ) ; setTranslationArrayStandaloneShortMonthNames ( standaloneShortMonthNames ) ; // Create default formatters for displaying the today button, and AD and BC dates, in // the specified locale. DateTimeFormatter formatForToday = DateTimeFormatter . ofLocalizedDate ( FormatStyle . MEDIUM ) . withLocale ( locale ) ; setFormatForTodayButton ( formatForToday ) ; DateTimeFormatter formatForDatesCE = InternalUtilities . generateDefaultFormatterCE ( locale ) ; setFormatForDatesCommonEra ( formatForDatesCE ) ; DateTimeFormatter formatForDatesBCE = InternalUtilities . generateDefaultFormatterBCE ( locale ) ; setFormatForDatesBeforeCommonEra ( formatForDatesBCE ) ; // Create an array of all the FormatStyle enum values, from short to long. FormatStyle [ ] allFormatStyles = new FormatStyle [ ] { FormatStyle . SHORT , FormatStyle . MEDIUM , FormatStyle . LONG , FormatStyle . FULL } ; // Create a set of default parsing formatters for the specified locale. ArrayList < DateTimeFormatter > parsingFormats = new ArrayList < DateTimeFormatter > ( ) ; DateTimeFormatter parseFormat ; for ( int i = 0 ; i < allFormatStyles . length ; ++ i ) { parseFormat = new DateTimeFormatterBuilder ( ) . parseLenient ( ) . parseCaseInsensitive ( ) . appendLocalized ( allFormatStyles [ i ] , null ) . toFormatter ( locale ) ; parsingFormats . add ( parseFormat ) ; } // Get any common extra parsing formats for the specified locale, and append them to // the list of parsingFormatters. ArrayList < DateTimeFormatter > extraFormatters = ExtraDateStrings . getExtraParsingFormatsForLocale ( locale ) ; parsingFormats . addAll ( extraFormatters ) ; // Save the parsing formats. setFormatsForParsing ( parsingFormats ) ; // Initialize the first day of the week. DayOfWeek firstDayOfWeekDefault = WeekFields . of ( locale ) . getFirstDayOfWeek ( ) ; setFirstDayOfWeek ( firstDayOfWeekDefault ) ; // Draw the calendar. zSkipDrawIndependentCalendarPanelIfNeeded = false ; zDrawIndependentCalendarPanelIfNeeded ( ) ; // Update the parent date picker text field if needed. zDrawDatePickerTextFieldIfNeeded ( ) ; }
setLocale This will set the locale for this DatePickerSettings instance and will set all other settings that depend on the locale to their default values .