Jasper reports 从jaser中的数据库检索日期

Jasper reports 从jaser中的数据库检索日期,jasper-reports,Jasper Reports,在mysql中,我将日期设置为datetime。但当我在jasper中检索值时,我得到的是空指针 net.sf.jasperreports.engine.JRException:从bean检索字段值时出错:new java.text.simpleDataFormat(“YYYY-MM-DD HH:MI:SS”).format($F{birthDate}) 请帮助我如何获得正确的日期。根据«日期和时间模式»中没有MI模式。因此,如果要定义分钟数,则必须使用m或mmpaten。此外,您还必须使用

在mysql中,我将日期设置为
datetime
。但当我在jasper中检索值时,我得到的是空指针

net.sf.jasperreports.engine.JRException:从bean检索字段值时出错:new java.text.simpleDataFormat(“YYYY-MM-DD HH:MI:SS”).format($F{birthDate})


请帮助我如何获得正确的日期。

根据«日期和时间模式»中没有
MI
模式。因此,如果要定义分钟数,则必须使用
m
mm
paten。此外,您还必须使用年的
y
模式、
d
dd
模式来定义月份中的天数。并使用
s
ss
秒,因为
s
代表毫秒:

new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format($F{birthDate})

看起来您希望将db字段定义与其字符串表示结合起来。我已经将你的代码样本缩进了4个空格,这样它可以正确地呈现错误信息,并引用错误信息,这样看起来更吸引人。
new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format($F{birthDate})