获取国家的货币代码时遇到问题。我的任务是获取用户的位置,了解他现在在哪个国家并获取该国家的货币代码。以下是从获取的位置获取国名和国家代码的代码:获取国家的货币代码
Geocoder gc = new Geocoder(this);
List<Address> addresses = gc.getFromLocation(
location.getLatitude(), location.getLongitude(), 5);
textView1.setText(addresses.get(0).getCountryName());
textView2.setText(addresses.get(0).getCountryCode());
这很好。现在我应该使用java.util.Currency
类来获得Currency
对象。我可以使用Currency.getInstance(Locale locale)
方法。但是Locale
类中没有构造函数,只允许将国家代码作为参数传递。意味着我无法为该国创建一个对象。这怎么解决?提前致谢。
有一个符合ISO-639语言组的构造函数'Locale(String language,String country)'。 – 2012-02-06 10:15:11
区域设置(String language,String country)? – 2012-02-06 10:17:04