The recommended way to set the standard Java language settings is to execute it through the shell locale / operating system settings. For example, on UNIX / LINUX, the default locale is determined by environment variables.
The following is information from the Java Internationalization FAQ :
Is it possible to set the default locale outside the application?
It depends on the implementation of the used Java platform. the default source standard is usually determined by the host system language. Sun JRE versions 1.4 and above allow you to override this by setting the user.language, user.country, and user.variant system properties from the command line. For example, to select Locale ("th", "TH", "TH") as the default initial locale, you should use:
java -Duser.language = th -Duser.country = TH -Duser.variant = TH MainClass
Since not all runtimes provide this feature, it should be for testing.
EDIT
The question asks:
I am looking specifically to change the date and time format to make it compatible with ISO-8601 (wartime), but I could not find the right tricks for this.
It looks like you want to selectively redefine some aspects of the current locale, rather than completely change it. An easy way to do this is to get the application to do the job; those. Use the specified date format, not the default format specified by the current locale. But if the application is closed, you may not be able to change it.
Perhaps you can get around this with the following approach:
- Find out how Java implements the resolution of language triples (country / language / variant) for local objects.
- For each locale that needs to be supported, subclasses of existing locale classes (etc.) to implement a new variant that uses ISO date and time formats.
- Create a JAR containing your own classes or resources and add it to the class path. (You may need to add a JAR to the bootclasspath, etc., to make this work).
Finally, if the application does not use language mechanisms to determine which date format to use, any changes based on the language change will have no effect.