The Windows XP systeminfo
command displays lots of stuff, but the relevant information is this:
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
To get equivalent information in Java, use Locale.getDefault()
to get the Locale that Java is using, and use methods on the Locale object such as getCountry()
, getLanguage()
to get details. The information is available using ISO codes and as human readable/displayable names.
Note that Locale.getDefault()
gives you the locale that Java picks up from the environment when it starts, this may or may not be the same as the "system" locale. To definitively get the "system" locale in Java you would need to do platform specific things. IMO, it is simpler to make sure that Java gets started with the system locale ... if you really need that information.
UPDATE: Apparently, Java 7 has changed the way that the locale information used by getDefault()
is determined on Windows; see https://stackoverflow.com/a/8319889/139985
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…