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.time
when the code is getting re-compiled on this machine. You should check a few things on this machine:
- If the library has been imported successfully.
- If there is any setting to import the most appropriate types automatically if some types are missing.
- If the JDK version is the same as that of your local machine.
Original answer:
You can use TextStyle.SHORT_STANDALONE
import java.util.Locale;
import org.threeten.bp.LocalDate;
import org.threeten.bp.format.TextStyle;
class Main {
public static void main(String[] args) {
LocalDate localDate = LocalDate.of(2019, 12, 20);
String dayOfWeek = localDate.getDayOfWeek().getDisplayName(TextStyle.SHORT_STANDALONE, Locale.GERMAN);
System.out.println(dayOfWeek);
}
}
Output:
Fr
I do not get a dot in the output for TextStyle.SHORT
on my system though. Nevertheless, if you still want to use TextStyle.SHORT
and not have the dot (or any punctuation mark) with it, you can replace every punctuation mark with a blank string.
import java.util.Locale;
import org.threeten.bp.LocalDate;
import org.threeten.bp.format.TextStyle;
class Main {
public static void main(String[] args) {
LocalDate localDate = LocalDate.of(2019, 12, 20);
String dayOfWeek = localDate.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.GERMANY);
System.out.println(dayOfWeek);
// Remove all punctuation mark
dayOfWeek = dayOfWeek.replaceAll("\\p{Punct}", "");
System.out.println(dayOfWeek);
}
}
Output:
Fr
Fr
Note: The result for TextStyle.SHORT
changes with java.time
API as shown below:
import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.Locale;
class Main {
public static void main(String[] args) {
LocalDate localDate = LocalDate.of(2019, 12, 20);
String dayOfWeek = localDate.getDayOfWeek().getDisplayName(TextStyle.SHORT_STANDALONE, Locale.GERMANY);
System.out.println(dayOfWeek);
dayOfWeek = localDate.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.GERMANY);
System.out.println(dayOfWeek);
// Remove all punctuation mark
dayOfWeek = dayOfWeek.replaceAll("\\p{Punct}", "");
System.out.println(dayOfWeek);
}
}
Output:
Fr
Fr.
Fr