• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic