【发布时间】:2017-07-13 13:29:26
【问题描述】:
我正在尝试在我的 jqGrid 中转换 jodaDateFormat。
我的 Entity 类中的声明是:
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
@DateTimeFormat(iso=ISO.DATE)
@Column(nullable=false)
private LocalDate dateStart;
为了在视图中看到这个日期,我尝试在 tagx 文件中插入这个 javascript 转换:
<script type="text/javascript">
<![CDATA[
jodaLDFormatter = function (cellValue, options) {
if(cellValue) {
return $.datepicker.formatDate(
'dd/MM/yyyy',
new Date(cellValue['year'],
cellValue['monthOfYear']-1,
cellValue['dayOfMonth']));
} else {
return '';
}
};
在JSP页面中我是这样声明列的:
<table:jqcolumn id="l_list_dateStart" property="dateStart" formatter="jodaLDFormatter"/>
但我得到了这个:(来自页面来源)
<td role="gridcell" style="" title="NaN/NaN/NaNNaN" aria-describedby="l_list_dateStart">NaN/NaN/NaNNaN</td>
我不想转换字符串中的每个日期以便在 jqGrid 中看到它!
什么是正确的方法?!
【问题讨论】:
-
您需要在 formatoptions 中设置 srcformat 和 newformat 选项。默认的 srcformat 是 ISO 日期 (Y-m-d)
标签: jsp datepicker jqgrid jodatime jsp-tags