This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Alessandro Ilardo
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic