English 中文(简体)
Java月的名称
原标题:Get name of the month in Java

我在计划上将11-12年之间的ger化转换成相应的月名称。 (例如1-> 1月2日至> 2月)等,在一份说明中使用 Java日历级。

注:我只使用 Java日历类。 Don t建议任何开关或铺面办法。

感谢。

最佳回答
问题回答

页: 1 这种方法可以启动。 在一个发言中作出这一规定是一项可怕的要求。

tl;dr

Month.of( 12 ).getDisplayName( TextStyle.FULL , Locale.US )

......

Month.DECEMBER.getDisplayName( TextStyle.FULL , Locale.US )

12月

Using java.time

获取一个月当地化名称的现代途径是java。 页: 1 这一类别是 j的一部分。 现在,一揽子时间计划取代诸如<代码>DateCalendar等老旧的遗产日记。

• 为地方化,具体规定:

  • TextStyle to determine how long or abbreviated should the string be.
  • Locale to determine (a) the human language for translation of name of day, name of month, and such, and (b) the cultural norms deciding issues of abbreviation, capitalization, punctuation, separators, and such.

例码。

Month month = Month.of( 7 );
String outputConstantName = month.toString();
String outputMonthNameEnglish = month.getDisplayName( TextStyle.FULL , Locale.US );
String outputMonthQuébec = month.getDisplayName( TextStyle.FULL , Locale.CANADA_FRENCH );

月: 日 本

页: 1

页: 1

采用<代码>Month,按名称而不是月数对 objects,可以是手法,易于阅读,较少发生错误。

String output = Month.JULY.getDisplayName( TextStyle.FULL , Locale.US ) ;

About java.time

legacyjava.util。 日期<<>,rel=“nofollow noretinger”>Calendar , &rel=“nofollow noreting”code<>>>>>

Joda-time Project,现载于,为向

更多学习,见 rel=“nofollow noreferer”>Oracle Tutorial 。 并寻找许多例子和解释。 具体定义是JSR 310

获取ava。 时间段

The ThreeTen-Extra Project Expansion java.time with addition levels. 该项目是今后可能增加 j的一个证明。 时间。 http://www. 33ten.org/ iii/extra/apidocs/org/ 3ten/extra/Interval.html





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签