aspose file tools*
The moose likes Beginning Java and the fly likes question about locale Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "question about locale" Watch "question about locale" New topic
Author

question about locale

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
hello
i use chinese windows2000 operating system,see my following code:

import java.text.DateFormat;
import java.util.*;
public class MyDate {

public static void main(String[] argv){

Locale countries[];
Locale locale=new Locale("en");
countries=locale.getAvailableLocales();
for(int i=0;i<countries.length;i++){
System.out.println(countries[i].getDisplayCountry());
}
}
}


i want to display english country name list,but it always give me the chinese name,why?
thank you!
John Spindler
Greenhorn

Joined: Feb 12, 2002
Posts: 28
I am not sure what exactly you are asking to do here but if it is to show all countries that use the English Language then you should use the getDisplayLanguage() method, like so:

Hope that helps.. if not let me know.

Slight edit to fit in page width -- Carl
[ April 08, 2002: Message edited by: Carl Trusiak ]
zhebincong
Greenhorn

Joined: Jan 14, 2002
Posts: 11
i want to display all of the countries in the world by using english,not only the countries that speak english!
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Answered here.
Also, please read our user name policy here and modify your display name accordingly. We need to see a space between Zhebin and Cong. Thanks.
[ April 08, 2002: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
You need to adjust your base Locale. This is what controls the display. I tried to use Chinese for the example but, I don't have a character set to handle that so, I used French instead.
Just before your loop call:
Locale.setDefault(Locale.FRENCH);
You can use any of the constants such as ENGLISH Since my base local is that, I shifted it to French to see the difference.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: question about locale