标签:
// Calendar.class // 如果直接设置月份或者星期时请注意±1,使用SimpleDateFormat则无此问题。 /* * #DAY_OF_WEEK * public final static int SUNDAY = 1; * public final static int MONDAY = 2; * public final static int TUESDAY = 3; * public final static int WEDNESDAY = 4; * public final static int THURSDAY = 5; * public final static int FRIDAY = 6; * public final static int SATURDAY = 7; * * #MONTH public * final static int JANUARY = 0; * public final static int FEBRUARY = 1; * public final static int MARCH = 2; * public final static int APRIL = 3; * public final static int MAY = 4; * public final static int JUNE = 5; * public final static int JULY = 6; * public final static int AUGUST = 7; * public final static int SEPTEMBER = 8; * public final static int OCTOBER = 9; * public final static int NOVEMBER = 10; * public final static int DECEMBER = 11; * public final static int UNDECIMBER = 12; */
Map<String, Integer> java.util.Calendar.getDisplayNames(int field, int style, Locale locale)
field 可以显示的有:几月,星期几
style 可能的样式:缩写,全拼,全部
localse 所有可能的时区
public static void main(String[] args) { Calendar c = Calendar.getInstance(); System.out.println(c.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.UK)); System.out.println(c.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.UK)); System.out.println(c.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.ALL_STYLES, Locale.UK)); System.out.println(c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.UK)); System.out.println(c.getDisplayNames(Calendar.MONTH, Calendar.LONG, Locale.UK)); System.out.println(c.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.UK)); }
结果:
{Saturday=7, Thursday=5, Monday=2, Tuesday=3, Wednesday=4, Friday=6, Sunday=1} {Thu=5, Wed=4, Sun=1, Sat=7, Fri=6, Tue=3, Mon=2} {Thu=5, Thursday=5, Saturday=7, Monday=2, Wed=4, Sun=1, Tuesday=3, Sat=7, Wednesday=4, Fri=6, Tue=3, Mon=2, Friday=6, Sunday=1} Wednesday {October=9, January=0, April=3, February=1, August=7, June=5, November=10, July=6, May=4, December=11, March=2, September=8} June
标签:
原文地址:http://www.cnblogs.com/zno2/p/4583147.html