Calling localDate.getDayOfWeek().getDisplayName in my UnitTest running on CircleCI returns a different value compared to running the UnitTest locally.
Here is the simplified sample code:
LocalDate localDate = LocalDate.of(2019, 12, 20);
String dayOfWeek = localDate.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.GERMANY);
assertEquals("Fr", dayOfWeek); // actual = "Fr."
dayOfWeek contains a '.' only on CI but I don't get why and how to fix it (properly).
This is the error log of the UnitTest:
junit.framework.ComparisonFailure: expected:<Fr[.]> but was:<Fr[]>
..
Hint: I'm using ThreeTen Android Backport
UPDATE As mentioned by @OleV.V.and @Arvind Kumar Avinash the reason for the different behaviour (local and CI) is the difference in the JDK versions (local 8.x and CI 11.x).
This leaves a part of my question open: "How to fix this properly?" This the correct/only way to change the JDK version on my CI docker image?
Update:
After looking into the updated question, the problem seems to be because of missing library of ThreeTen Android Backport on the machine where CircleCI is running. In the absence of this library, probably it is defaulting to
java.timewhen the code is getting re-compiled on this machine. You should check a few things on this machine:Original answer:
You can use
TextStyle.SHORT_STANDALONEOutput:
I do not get a dot in the output for
TextStyle.SHORTon my system though. Nevertheless, if you still want to useTextStyle.SHORTand not have the dot (or any punctuation mark) with it, you can replace every punctuation mark with a blank string.Output:
Note: The result for
TextStyle.SHORTchanges withjava.timeAPI as shown below:Output: