This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Locale methods - Strange Behavior Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Locale methods - Strange Behavior" Watch "Locale methods - Strange Behavior" New topic
Author

Locale methods - Strange Behavior

nico dotti
Ranch Hand

Joined: Oct 09, 2007
Posts: 124
--------------------------------------
ANSWER:
Dope! I just figured it out LOL get available locales returns Locales based on country and language, so of course the ones based on language (lowercase) aren't going to have data for the country associated with them. The reason I got confused was I saw data for russia and then I didn't. But actually it was two different locales! (ru and ru_RU)
--------------------------------------
I'm doing a dump of dates based on the locales provided by the getAvailableLocales method of DateFormat. I loop through and display the country and language for each. What's strange is that for some iterations I don't see the country displayed, and then if I run the program again, I'll see it for that same country! For example here's a bit of the output (notice that there's no 'Turkey'):


If I run this code again, I may actually get the country output the next time through. What would cause this? My fear is that if I used this functionality in real life to fill about a collection of say available locales, and assumed that the elements had certain fields like countryName, countryDisplayName, etc., I would have inaccurate data. What am I missing?

My code:

[ December 05, 2007: Message edited by: nico dotti ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Locale methods - Strange Behavior
 
Similar Threads
please explain every line
Interpreting Date Objects
Stumped By HashSet
Problem in printing locale specific time
how to show all countries currency symbols