Locale passed to Tests is missing 'user.country.format'

Hi there, it seems that as of Gradle 2.1 (introduced I guess by this defect fixed GRADLE-3142) ‘user.country.format’ is no longer being set for forked tests, which is then breaking things that rely on that format (yes the tests shouldn’t be doing that)

I think that because the fix for that issue started including some locale params, the JVM is no longer adding the extra ones like ‘user.country.format’.

I think a fix would be to just add in ‘user.country.format’ (and user.language.format, user.language.display, user.country.format) to be passed along if they are provided as well.

My temp fix has been to just add ‘user.country.format’ to the list of system properties for tests in my build.gradle.



It’s not entirely clear what’s going on here. Would you be able to provide a build and reproducible instructions?

Gradle has never “managed” the user.language.format properties, so nothing should have actually changed here. it seems like there’s some inherent JVM behaviour regarding deriving those runtime values from some of the properties we newly managed.

If you can provide some instructions for reproducing the problem, it should be pretty straightforward to fix.

Cheers for the quick response Luke.

What I think is happening is that when we pass ‘user.country’ as a system property, the JVM stops automatically setting user.country.format.

Take this example …

import java.util.Locale;

public class Test {

	public static void main(String... args) {




If I run it as
java Test

The output is (I’m in New Zealand)


However as
java -Duser.country=US Test

The output is


So since GRADLE-3142 now means that user.country is set for the forked Test task, the forked task isn’t getting user.country.format set.

So yeah I think the fix is to just pass down user.country.format if it has been set … and I listed those other 3 properties because I imagine that they behave in the same way.

  • Steve

Not quite enough detail Steve.

However as

java -Duser.country=US Test

What do you mean by this? Gradle is not involved in this.

EDIT: nvm, I see that you are describing what happens with Gradle out of the picture.

What version of Java are you using?

I’ve raised GRADLE-3294 for this. Thanks for the report.

Same behaviour on both
JDK 1.7.0 60
JDK 1.8.0 05

Great thanks for that