code: public Locale getEffectiveLocale() {
  
  		// Priority 5: Default locale
  		Locale locale = Locale.getDefault();
  		boolean userHasLocaleString = false;
  
  		if (cachedUser != null) {
  
  			// Priority 2: User locale
  			final String userLocaleString = cachedUser.getLocale();
  			if (userLocaleString != null) {
  
  				userHasLocaleString = true;
  
  				try {
  					locale = LocaleUtils.toLocale(userLocaleString);
  				} catch (IllegalArgumentException e) {
  					locale = Locale.forLanguageTag(userLocaleString);
  				}
  			}
  
  		}
  
  		if (request != null) {
  
  			if (!userHasLocaleString) {
  
  				// Priority 4: Browser locale
  				locale = request.getLocale();
  
  				final Cookie[] cookies = request.getCookies();
  
  				if (cookies != null) {
  
  					// Priority 3: Cookie locale
  					for (Cookie c : cookies) {
  
  						if (c.getName().equals(LOCALE_KEY)) {
  
  							final String cookieLocaleString = c.getValue();
  
  							try {
  								locale = LocaleUtils.toLocale(cookieLocaleString);
  							} catch (IllegalArgumentException e) {
  								locale = Locale.forLanguageTag(cookieLocaleString);
  							}
  
  						}
  
  					}
  
  				}
  
  			}
  
  			// Priority 1: URL parameter locale
  			String requestedLocaleString = request.getParameter(LOCALE_KEY);
  			if (StringUtils.isNotBlank(requestedLocaleString)) {
  				try {
  					locale = LocaleUtils.toLocale(requestedLocaleString);
  				} catch (IllegalArgumentException e) {
  					locale = Locale.forLanguageTag(requestedLocaleString);
  				}
  			}
  
  		}
  
  		return locale;
  	}
docs: Determine the effective locale for this request.
  
  Priority 1: URL parameter "locale"
  Priority 2: User locale
  Priority 3: Cookie locale
  Priority 4: Browser locale
  Priority 5: Default locale
  
  @return locale