码迷,mamicode.com
首页 > 其他好文 > 详细

日期时间(二)

时间:2016-08-05 19:28:14      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:

 

   // 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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!