您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

获取所有可能的货币

获取所有可能的货币

在研究了ISO表和Currency类文档之后,您似乎可以将货币作为代码或语言环境了。并且Locale类有一个getAvailableLocales()方法

因此,代码为:

    public static Set<Currency> getAllCurrencies()
    {
        Set<Currency> toret = new HashSet<Currency>();
        Locale[] locs = Locale.getAvailableLocales();

        for(Locale loc : locs) {
            try {
                Currency currency = Currency.getInstance( loc );

                if ( currency != null ) {
                    toret.add( currency );
                }
            } catch(Exception exc)
            {
                // Locale not found
            }
        }

        return toret;
    }

希望这可以帮助。

其他 2022/1/1 18:26:07 有516人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶