org.joda.time.LocalDate converison

Request for help on DynamicReports

Moderator: ricardo

org.joda.time.LocalDate converison

Postby katitmukaan » Mon Nov 30, 2015 8:24 am

I'm just building my first reports with DynamicReports. Can anyone help with date type conversion problem:
I need to use custom java bean list as a data source for DR.
What would be the smoothest way to convert joda LocalDate and othe joda time types to either String or java.util.Data?

I tried ValueFormatter, but it seems to me that it only takes "DynamicReport-native" data types.
katitmukaan
 
Posts: 4
Joined: Mon Nov 30, 2015 7:49 am

Re: org.joda.time.LocalDate converison

Postby katitmukaan » Mon Nov 30, 2015 12:24 pm

Found it myself. Tanks to good examples in DynamicReport's web site.



Code: Select all
     col.column("StartDate", new SimpleExpression_datetime()


     private class SimpleExpression_datetime extends AbstractSimpleExpression<String> {
        private static final long serialVersionUID = 1L;

        @Override
        public String evaluate(ReportParameters reportParameters) {
            LocalDate localDate = reportParameters.getValue("startdate");
            return localDate.toString();
        }
    }
katitmukaan
 
Posts: 4
Joined: Mon Nov 30, 2015 7:49 am

Re: org.joda.time.LocalDate converison

Postby katitmukaan » Fri Dec 11, 2015 12:44 pm

Some how I managed to post my first question to this forum some days ago. Wonder how I did it. I just can't any more find out how new question can be added here. A button or link have to be somewhere, but very cleverly hided it is. Can someone help me on this. Of course there is also Stack Overflow, maybe it is anyway a better place to ask for help with DynamicReports.
katitmukaan
 
Posts: 4
Joined: Mon Nov 30, 2015 7:49 am

Re: org.joda.time.LocalDate converison

Postby ricardo » Mon Dec 14, 2015 1:53 pm

In the Help forum (click here http://www.dynamicreports.org/forum/viewforum.php?f=1), there is NEWTOPIC button that creates a new topic/question in the forum
ricardo
Site Admin
 
Posts: 1363
Joined: Sat Sep 18, 2010 4:47 pm
Name: Ricardo Mariaca

Re: org.joda.time.LocalDate converison

Postby florianschneider » Tue Aug 08, 2017 12:59 pm

I seemed to follow the same approach, but I keep on getting runtime exceptions, because the value I want to obtain in the expression subclass is not among the report fields .... Any hint on how I can use that expression API exactly?
florianschneider
 
Posts: 2
Joined: Tue Aug 08, 2017 11:55 am

Re: org.joda.time.LocalDate converison

Postby dpiemonte » Wed Aug 09, 2017 7:03 pm

you have to add the field to the report in addition of the column

Code: Select all
report.addField("startdate", LocalDate.class);
dpiemonte
 
Posts: 4
Joined: Tue May 09, 2017 2:49 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron