I'm trying to convert jodaDateFormat in my jqGrid.
The declaration in my Entity class is:
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
@DateTimeFormat(iso=ISO.DATE)
@Column(nullable=false)
private LocalDate dateStart;
To see this date in the view, I try to insert in the tagx file this javascript conversion:
<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 '';
}
};
In the JSP page I declare the column in this way:
<table:jqcolumn id="l_list_dateStart" property="dateStart" formatter="jodaLDFormatter"/>
but I obtain this: (from source of page)
<td role="gridcell" style="" title="NaN/NaN/NaNNaN" aria-describedby="l_list_dateStart">NaN/NaN/NaNNaN</td>
I don't want to convert every date in string for see it in jqGrid!
What's the right way?!
I think that you don't pass the Joda object to the view. Probably you send from your controller a vector like [day, month, year]
.
If my guess is correct, you can add this inside your colmodel
:
formatter: 'date', srcformat:'dd/mm/yy', date:'true'