permaculture playing cards*
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 Murach's Java Servlets and JSP this week in the Servlets 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
Stumped By HashSet
how to show all countries currency symbols
Interpreting Date Objects
Problem in printing locale specific time