aspose file tools*
The moose likes Beginning Java and the fly likes Calendar - get(Calendar.MONTH) doesn't match Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calendar - get(Calendar.MONTH) doesn Watch "Calendar - get(Calendar.MONTH) doesn New topic
Author

Calendar - get(Calendar.MONTH) doesn't match

Alessandro Ilardo
Ranch Hand

Joined: Dec 23, 2005
Posts: 218
Hi there,
I need you help regarding this


18:45:09,539 DEBUG [AttachmentImplBean] [findAllAttachement] Calendar preference -> Fri Mar 14 00:00:00 CET 2008
18:45:09,544 INFO [STDOUT] Hibernate:
select
attachment0_.id as id90_,
attachment0_.title as title90_,
attachment0_.description as descript3_90_,
attachment0_.recordCalendar as recordCa4_90_,
attachment0_.sysPath as sysPath90_,
attachment0_.fileSize as fileSize90_,
attachment0_.mime as mime90_,
attachment0_.recByUser as recByUser90_,
attachment0_.cat_id as cat9_90_
from
Attachment attachment0_
where
month(attachment0_.recordCalendar)=?
and year(attachment0_.recordCalendar)=?
and attachment0_.cat_id=?
order by
attachment0_.recordCalendar DESC
18:45:09,602 INFO [IntegerType] could not bind value 'java.util.GregorianCalendar[time=1205449200000,areFieldsSet=true,
areAllFieldsSet=true,lenient=true,
zone=sun.util.calendar.ZoneInfo[id="Europe/San_Marino",offset=3600000,
dstSavings=3600000,useDaylight=true,transitions=169,
lastRule=java.util.SimpleTimeZone[id=Europe/San_Marino,
offset=3600000,dstSavings=3600000,useDaylight=true,
startYear=0,startMode=2,startMonth=2,startDay=-1,
startDayOfWeek=1,startTime=3600000,startTimeMode=2,
endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,
endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,
minimalDaysInFirstWeek=4,ERA=1,YEAR=2008,
MONTH=2,WEEK_OF_YEAR=11,WEEK_OF_MONTH=2,
DAY_OF_MONTH=14,DAY_OF_YEAR=74,DAY_OF_WEEK=6,
DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=0,
HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,
ZONE_OFFSET=3600000,DST_OFFSET=0]' to parameter: 1; java.util.GregorianCalendar


I don't understand why calendar returns as MONTH=2 (February) instead of 3(March)
I also tried with lenient set to false, same thing.

Any help?
Thanks in advance
[ March 14, 2008: Message edited by: Alessandro Ilardo ]

trying to decode a woman mind....
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Take a look at the API for Calendar:
MONTH

public static final int MONTH

Field number for get and set indicating the month. This is a calendar-specific value. The first month of the year in the Gregorian and Julian calendars is JANUARY which is 0; the last depends on the number of months in a year.

Since JANUARY is 0, FEBRUARY is 1, and MARCH is 2.
[ March 14, 2008: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calendar - get(Calendar.MONTH) doesn't match