我在计划上将11-12年之间的ger化转换成相应的月名称。 (例如1-> 1月2日至> 2月)等,在一份说明中使用 Java日历级。
注:我只使用 Java日历类。 Don t建议任何开关或铺面办法。
感谢。
我在计划上将11-12年之间的ger化转换成相应的月名称。 (例如1-> 1月2日至> 2月)等,在一份说明中使用 Java日历级。
注:我只使用 Java日历类。 Don t建议任何开关或铺面办法。
感谢。
rel=“nofollow noreferer”>。 班级不是在获得地方化月名称时使用的最佳班级。
以下是仅使用<代码>Calendar类别(1月1日)获得<编码>t<<>>t规定的月份名称的实例:
// Month as a number.
int month = 1;
// Sets the Calendar instance to the desired month.
// The "-1" takes into account that Calendar counts months
// beginning from 0.
Calendar c = Calendar.getInstance();
c.set(Calendar.MONTH, month - 1);
// This is to avoid the problem of having a day that is greater than the maximum of the
// month you set. c.getInstance() copies the whole current dateTime from system
// including day, if you execute this on the 30th of any month and set the Month to 1
// (February) getDisplayName will get you March as it automatically jumps to the next
// Month
c.set(Calendar.DAY_OF_MONTH, 1);
// Returns a String of the month name in the current locale.
c.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault());
上述法典将在本系统中重新命名。
如果需要另一个地方, Locale
<>http://java.sun.com/javase/6/docs/api/java/util/ locale.html> rel=“nofollow noreferer”><>>>>>
使用<代码>DateFormatSymbols
Proudly copied and pasted from 。
import java.text.*;
String getMonthForInt(int m) {
String month = "invalid";
DateFormatSymbols dfs = new DateFormatSymbols();
String[] months = dfs.getMonths();
if (m >= 0 && m <= 11 ) {
month = months[m];
}
return month;
}
页: 1 这种方法可以启动。 在一个发言中作出这一规定是一项可怕的要求。
Month.of( 12 ).getDisplayName( TextStyle.FULL , Locale.US )
......
Month.DECEMBER.getDisplayName( TextStyle.FULL , Locale.US )
12月
获取一个月当地化名称的现代途径是java。 页: 1 这一类别是 j的一部分。 现在,一揽子时间计划取代诸如<代码>Date
和Calendar
等老旧的遗产日记。
• 为地方化,具体规定:
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 ) ;
legacy。 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.htmljava.util。 日期
<<>>,rel=“nofollow noretinger”>Calendar
, &rel=“nofollow noreting”code<>>>>>
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 ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
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 ...
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 ...
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....
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 ...