如何从日历中获取月份名称? [英] How to get Month Name from Calendar?

查看:40
本文介绍了如何从日历中获取月份名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道的时候,有没有班轮来获取月份的名称

Is there a oneliner to get the name of the month when we know

int monthNumber = calendar.get(Calendar.MONTH)

或者最简单的方法是什么?

Or what is the easiest way?

推荐答案

您也将获得这种方式.

  String getMonthForInt(int num) {
        String month = "wrong";
        DateFormatSymbols dfs = new DateFormatSymbols();
        String[] months = dfs.getMonths();
        if (num >= 0 && num <= 11 ) {
            month = months[num];
        }
        return month;
    }

这篇关于如何从日历中获取月份名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆