I have a code where i am getting defaultlocale using locale class.On windows it returns me "en_us" but on unix it returns me "en".How do i make it consistent on both the platforms
locale -a will list available locales for your UNIX box. locale will show your current locale settings. On my sun box, setting LANG=en_US.UTF-8 produces the results you want. For example:
Code:
import java.util.*;
public class LocaleTest {
public static void main(String[] args) {
System.getProperties().list(System.out);
System.out.println(Locale.getDefault());
System.out.println(new Date());
}
}
Produces the following outputs depending on the locale setting:
Code:
LANG=en_GB java LocaleTest
...
en_GB <-- the locale
Tue Feb 25 10:57:39 GMT 2003
LANG=en_US.UTF-8 java LocaleTest
...
en_US <-- the locale
Tue Feb 25 10:58:13 GMT 2003
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.