读书人

Calendar的有关问题

发布时间: 2012-02-27 10:00:22 作者: rapoo

Calendar的问题
Calendar c = Calendar.getInstance();
//下面这两行一样么?
c.add(Calendar.WEEK_OF_MONTH, -1);
c.add(Calendar.WEEK_OF_YEAR, -1);

[解决办法]
Adds or subtracts the specified amount of time to the given calendar field, based on the calendar's rules. For example, to subtract 5 days from the current time of the calendar, you can achieve it by calling:
add(Calendar.DAY_OF_MONTH, -5).
是的



[解决办法]
WEEK_OF_MONTH是相对于这个月是第几个星期。
WEEK_OF_YEAR是相对于今年是第几个星期。

[解决办法]
没有区别,之所以提供这两个参数时便于你对业务的理解。

读书人网 >J2SE开发

热点推荐