Relative Dates - DateRange class

0

I trying to use the DateRange parameter. I followed the instructions from the iReport PDF. That's my code:

I have an error when I run the report:

Compilation exceptions: com.jaspersoft.ireport.designer.compiler.ErrorsCollector@91c832
 
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
calculator_all32op_1360591932552_649225: 131: unable to resolve class DateRangeBuilder 
 @ line 131, column 22.
calculator_all32op_1360591932552_649225: 207: unable to resolve class DateRangeBuilder 
 @ line 207, column 22.
calculator_all32op_1360591932552_649225: 283: unable to resolve class DateRangeBuilder 
 @ line 283, column 22.
3 errors
 
    at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:113)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:201)
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:240)
    at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:156)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:439)
    at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:528)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
 
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
calculator_all32op_1360591932552_649225: 131: unable to resolve class DateRangeBuilder 
 @ line 131, column 22.
calculator_all32op_1360591932552_649225: 207: unable to resolve class DateRangeBuilder 
 @ line 207, column 22.
calculator_all32op_1360591932552_649225: 283: unable to resolve class DateRangeBuilder 
 @ line 283, column 22.
3 errors
 
    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296)
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:829)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:511)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:487)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464)
    at net.sf.jasperreports.compilers.JRGroovyCompiler.compileUnits(JRGroovyCompiler.java:109)
    ... 7 more
samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 5 months ago
I am having the same problem. Anyone?
aiklamha1 - 6 years 1 month ago
Hi, I solved the problem. I changed the default expression from new DateRangeBuilder("DAY-1").toDateRange() to new net.sf.jasperreports.types.date.DateRangeBuilder("DAY-1").toDateRange()
aiklamha1 - 6 years 1 month ago

2 Answers:

1

Reposting aiklamha1 solution as an answer:

Just change the default expression from new DateRangeBuilder("DAY-1").toDateRange() to new net.sf.jasperreports.types.date.DateRangeBuilder("DAY-1").toDateRange()

Note:

Remember that when using this option the parameter class has to be set to DateRange (net.sf.jasperreports.types.date.DateRange). And this parameters are not date (java.util.dates) but ranges, so if you need to print (show) them in your report in a text field and use the patterns; you can use the getStart() or getEnd() methods.
for example:

 

Check in the iReport Ultimate Guide Chapter 6.2.4 (http://community.jaspersoft.com/documentation) for a full example.

 

 

marianol's picture
4267
Joined: Sep 13 2011 - 8:04am
Last seen: 6 months 3 weeks ago
0

Now it works! thanks!

 

I have just one question, now my parameter have a default value expression:

new net.sf.jasperreports.types.date.DateRangeBuilder("MONTH").toDateRange()

Is it possible to replace "MONTH" with a parameter ? For example the user select in a list last month or last week and the value changes..

Is that possible?

 

samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 5 months ago
Feedback
randomness