我是jasper报道的新手。我已经使用iReport 3.5.2成功创建了报告,在iReport中日期类型是java.sql.Timestamp并将日期输入视为(Wed 12/06/2013)我正在使用Eclipse IDE并在servlet代码中格式化日期,但是时间戳价值即将到来(2013-06-12 00:00:00.000),它显示空的碧玉报告。我正在使用以下罐子: -
公地BeanUtils的-1.5.jar
公地集合-2.1.jar
公共沼气池-1.7.jar
共享记录-1.0.2.jar
共享记录-API-1.0.2.jar
Groovy的全1.5.5.jar
iText的 - 2.1.5.jar
JasperReports的-3.5.2.jar
JDT-compiler.jar
jfreechart的-1.0.0-rc1.jar
JTDS-1.2.jar
请找到下面的servlet代码,请帮我显示数据报告。
public String generateReport(HttpServletRequest request,HttpServletResponse response)
{
try
{
Connection connection = null;
JasperReport jasperReport = null;
JasperPrint jasperPrint=null;
Date today = null;
Timestamp date = null;
String dateString = "";
connection = EmployeeJDBCUtil.getConnection();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd/MM/yyyy);
try {
dateString = dateFormat.format(new Date());
today = dateFormat.parse(dateString);
Timestamp ts = new Timestamp(today.getTime());
} catch (ParseException e1) {
e1.printStackTrace();
}
Map parameters = new HashMap();
parameters.put("Date", ts );
String report_File = "D:/timesheet/EmployeeTimeSheet/WebContent/TimeSheet2.jrxml";
File report_FileName = new File(report_File);
if(report_FileName.exists())
{
try {
JasperDesign jasperDesign = JRXmlLoader.load(report_File);
jasperReport = JasperCompileManager.compileReport(jasperDesign);
jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,connection);
JasperExportManager.exportReportToPdfFile(jasperPrint, "D:/sample.pdf");
JasperViewer.viewReport(jasperPrint);
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally
{
if(connection != null)
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return "index.jsp";
}