作者:手机用户2602897411 | 来源:互联网 | 2023-10-11 14:30
IcantseewhereImgoingwrongwiththecodebelow,itsprobablysomethingobviousbutImtoobl
I can't see where I'm going wrong with the code below, its probably something obvious but I'm too blind to see it at this stage. I'm passing a date of "01/01/2009" to an instance of calendar. I then try and set the month to 2 for March and the output I see is
我无法看到下面的代码我出错了,它可能是显而易见的但我现在太盲目了。我将“01/01/2009”的日期传递给日历实例。然后我尝试将月份设置为3月份,我看到的输出是
formatted: 01/01/2009
cal month: 2
cal月:2
cal.set( Calendar.MONTH, mth ); //mth = int 2
log.debug("formatted: " + formatter.format(cal.getTime()));
log.debug("cal month: "+Integer.valueOf(cal.get(Calendar.MONTH)).toString());
When I set the Calendar.DAY to the max value the date comes out as 31/01/2009
当我将Calendar.DAY设置为最大值时,日期为31/01/2009
Why does my setting of the Month not take?
为什么我的月份设置没有采取?
3 个解决方案