I'm using DynamicReports API for building reports.
I'm setting the Locale of the report and format the Date columns of the report, but the Dates are always formatted like 10/12/2009 10:54:44 AM no matter what the Locale is.
The code looks like:
rep.setTemplate(Templates.reportTemplate.setLocale(res.getLocale()));
...
if (rs.getString(i).contains("00:00:00"))
rep.addColumn(col.column(title, name, type.dateType()));
else
rep.addColumn(col.column(title, name, type.dateYearToSecondType()));
Is there a way to automatically format dates regarding to the Locale of the report or have I to use a custom ValueFormatter?
I also tryed the Parameter Map with no success
JasperReportBuilder rep = report()
.setDataSource(query, conn.getConnection())
.setParameter(JRParameter.REPORT_LOCALE, res.getLocale());
.setTemplate(Templates.reportTemplate.setLocale(res.getLocale()));
There is no way to automatically format the dates. The only way is to use patterns for the date column in respect to the locale.
TextColumnBuilder<Date> column = col.column(title, name, type.dateType());
if (res.getLocale().equals("EN") {
column.setPattern("dd.MM.yyyy");
}
else if (res.getLocale().equals("US") {
column.setPattern("MM/dd/yyyy");
}
else {
...
}
rep.addColumn(column);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With