Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Calendar/GregorianCalender exception(Can not convert the value of java.util.GregorianCalendar to Date type.)
Calendar/GregorianCalender exception [message #804267] Wed, 22 February 2012 11:59 Go to next message
Ludwig Moser is currently offline Ludwig Moser
Messages: 333
Registered: July 2009
Senior Member
obviously i know what causes the exception.
data type is defined as date, my java object is Calendar (which contains a date)

so is there a way to tell birt it shall call .getTime() on my calendar object to gain the date?
some sort of Converter / Dataprovider which converts like:
public static Date toDate(Calendar cal) {
return cal.getTime();
}

as this would resolve the issue...

Quote:

org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred. See next exception for more information.
Can not convert the value of java.util.GregorianCalendar[time=1327398408340,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,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=2012,MONTH=0,WEEK_OF_YEAR=4,WEEK_OF_MONTH=4,DAY_OF_MONTH=24,DAY_OF_YEAR=24,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=10,HOUR_OF_DAY=10,MINUTE=46,SECOND=48,MILLISECOND=340,ZONE_OFFSET=3600000,DST_OFFSET=0] to Date type.
at org.eclipse.birt.data.engine.core.DataException.wrap(DataException.java:123)
at org.eclipse.birt.data.engine.expression.ExprEvaluateUtil.evaluateExpression(ExprEvaluateUtil.java:86)
at org.eclipse.birt.data.engine.impl.BindingColumnsEvalUtil.evaluateValue(BindingColumnsEvalUtil.java:201)
at org.eclipse.birt.data.engine.impl.BindingColumnsEvalUtil.getColumnsValue(BindingColumnsEvalUtil.java:161)
at org.eclipse.birt.data.engine.impl.ResultIterator.prepareCurrentRow(ResultIterator.java:778)
at org.eclipse.birt.data.engine.impl.ResultIterator.nextRow(ResultIterator.java:527)
Re: Calendar/GregorianCalender exception [message #804413 is a reply to message #804267] Wed, 22 February 2012 15:44 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

In the binding expression you should be able to add something like:

importPackage(Packages.java.util);
var mydate = yourcalobject.getTime();

Jason

On 2/22/2012 6:59 AM, Ludwig Moser wrote:
> obviously i know what causes the exception.
> data type is defined as date, my java object is Calendar (which contains
> a date)
>
> so is there a way to tell birt it shall call .getTime() on my calendar
> object to gain the date?
> some sort of Converter / Dataprovider which converts like:
>
> public static Date toDate(Calendar cal) {
> return cal.getTime();
> }
>
> as this would resolve the issue...
>
> Quote:
>> org.eclipse.birt.data.engine.core.DataException: A BIRT exception
>> occurred. See next exception for more information.
>> Can not convert the value of
>> java.util.GregorianCalendar[time=1327398408340,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,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=2012,MONTH=0,WEEK_OF_YEAR=4,WEEK_OF_MONTH=4,DAY_OF_MONTH=24,DAY_OF_YEAR=24,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,HOUR=10,HOUR_OF_DAY=10,MINUTE=46,SECOND=48,MILLISECOND=340,ZONE_OFFSET=3600000,DST_OFFSET=0]
>> to Date type.
>> at
>> org.eclipse.birt.data.engine.core.DataException.wrap(DataException.java:123)
>>
>> at
>> org.eclipse.birt.data.engine.expression.ExprEvaluateUtil.evaluateExpression(ExprEvaluateUtil.java:86)
>>
>> at
>> org.eclipse.birt.data.engine.impl.BindingColumnsEvalUtil.evaluateValue(BindingColumnsEvalUtil.java:201)
>>
>> at
>> org.eclipse.birt.data.engine.impl.BindingColumnsEvalUtil.getColumnsValue(BindingColumnsEvalUtil.java:161)
>>
>> at
>> org.eclipse.birt.data.engine.impl.ResultIterator.prepareCurrentRow(ResultIterator.java:778)
>>
>> at
>> org.eclipse.birt.data.engine.impl.ResultIterator.nextRow(ResultIterator.java:527)
>>
>
Re: Calendar/GregorianCalender exception [message #805081 is a reply to message #804413] Thu, 23 February 2012 10:06 Go to previous message
Ludwig Moser is currently offline Ludwig Moser
Messages: 333
Registered: July 2009
Senior Member
thanks for the hint, i adopted the generating code for the report.
now it simply adds .getTime() to the getter of the property

for example:
getBirthday().getTime()
instead of
getBirthday()
Previous Topic:dynamic hyperlinking in birt 3.7.1.v20110905-809u7NFT0z0-TWCm5MjN7w
Next Topic:Hexadecimal values on chart
Goto Forum:
  


Current Time: Fri Sep 19 16:07:25 GMT 2014

Powered by FUDForum. Page generated in 0.10434 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software