This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Below you may find a code snippet which is called from a main method where I would like to display the time as per the country code. Somehow it is displaying the current system time but not the time in USA. I am testing from Hungary.
Then you are going to have to do what Rok suggested. For each country go through that list and identify the time zone it uses. Then make a map from country code to time zone, and use that.
I already explained why your original idea wouldn't work. And because it won't work for a considerable number of countries, there would be no point in trying to implement it for the rest. What would it do for a country with several time zones? Throw an exception? Pick one time zone at random? Whatever it did wouldn't be of any use. So there's no point in doing that. So people didn't.