2121import java .io .StringWriter ;
2222import java .time .LocalDate ;
2323import java .util .List ;
24+ import java .util .Locale ;
2425import java .util .Optional ;
2526import java .util .stream .Collectors ;
2627
@@ -84,6 +85,9 @@ public class App extends Application {
8485 @ Override
8586 public void init () throws Exception {
8687 LOG .info ("Starting KeepTime." );
88+
89+ setLocaleToEnglish ();
90+
8791 final DefaultExceptionHandler defaultExceptionHandler = new DefaultExceptionHandler ();
8892 defaultExceptionHandler .register ();
8993
@@ -102,6 +106,22 @@ public void init() throws Exception {
102106 model .setSpringContext (springContext );
103107 }
104108
109+ private void setLocaleToEnglish () {
110+ final Locale systemDefaultLocale = Locale .getDefault ();
111+ final Locale wantedApplicationLocale = Locale .ENGLISH ;
112+
113+ if (systemDefaultLocale .getLanguage ().equals (wantedApplicationLocale .getLanguage ())){
114+ LOG .debug ("Application Locale already is '{}'. Nothing to do." , wantedApplicationLocale );
115+ return ;
116+ }
117+
118+ LOG .info ("Setting application Locale to '{}', was '{}'." , wantedApplicationLocale , systemDefaultLocale );
119+ Locale .setDefault (wantedApplicationLocale );
120+ Locale .setDefault (Locale .Category .DISPLAY , wantedApplicationLocale );
121+ // keep system locale for format conversions (date, currency, numbers)
122+ Locale .setDefault (Locale .Category .FORMAT , systemDefaultLocale );
123+ }
124+
105125 @ Override
106126 public void start (final Stage primaryStage ) {
107127 LOG .info ("Initialising the UI" );
0 commit comments