The default locale of your application is determined in three ways.
First, unless you have explicitly changed the default, the
getDefault() method returns the locale that was initially determined
by the Java Virtual Machine (JVM) when it first loaded. That is, the
JVM determines the default locale from the host environment. The host
environment's locale is determined by the host operating system and
the user preferences established on that system.
Second, on some Java runtime implementations, the application user can
override the host's default locale by providing this information on
the command line by setting the user.language, user.country, and
user.variant system properties. [Source]
I think you are a victim of the first part, so second never gets a chance.
Instead, what you can do is in your unit test (or maybe a base class thereof) set the default locale programatically as stated later in the same text:
Third, your application can call the setDefault(Locale aLocale)
method. The setDefault(Locale aLocale)
method lets your application
set a systemwide resource. After you set the default locale with this
method, subsequent calls to Locale.getDefault()
will return the newly
set locale.
static{
Locale.setDefault(Locale.UK);
}
user.country
instead ofuser.region
? – Aristarchus