I'm not sure what you mean, but "it doesn't work as expected," but you are using the Locale constructor incorrectly. The first language and country are separated by an underscore, not a minus sign, and the only String argument constructor is for the language only. Thus, you have two valid options:
new Locale("pt", "BR")
or
StringUtils.parseLocaleString("pt_BR")
source
share