月份名称作为字符串 [英] Month name as a string

查看:13
本文介绍了月份名称作为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将月份名称作为字符串返回,例如May"、September"、November".

I'm trying to return the name of the month as a String, for instance "May", "September", "November".

我试过了:

int month = c.get(Calendar.MONTH);

但是,这会返回整数(分别为 5、9、11).如何获取月份名称?

However, this returns integers (5, 9, 11, respectively). How can I get the month name?

推荐答案

使用getDisplayName.

对于早期的 API 使用 String.format(Locale.US,"%tB",c);

For earlier API's use String.format(Locale.US,"%tB",c);

这篇关于月份名称作为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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