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

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

问题描述

我试图返回月份的名称作为一个字符串,如五一,月,月。

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?

推荐答案

使用<一个href="http://developer.android.com/reference/java/util/Calendar.html#getDisplayName%28int,%20int,%20java.util.Locale%29">getDisplayName.

对于早期的API使用的String.Format(Locale.US,%TB,C);

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

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

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