Reputation: 964
I have a spring MVC java application and I'm serializing joda DateTime to json.
When I examine the output through the browser the DateTime serialized data looks like this:
startDate: 1323147660000
I'm not sure which format this data is in. I've tried many different combinations of srcformat and newformat format options including the following based on this post:
{srcformat:'U', newformat:'m/d/Y'}
My hunch is that this is the number of milliseconds since the epoch but I'm not sure how to use it correctly within jqgrid.
Thanks in advance for any help.
Upvotes: 2
Views: 7473
Reputation: 340763
Actually the milliseconds from epoch format was supported out-of-the-box in one of the previous versions of jqGrid. Unfortunately it has been dropped for an unknown reason.
Here is a workaround:
{
name:'startDate',
label: 'Start date'
formatter: function(cellValue, options) {
if(cellValue) {
return $.fmatter.util.DateFormat(
'',
new Date(+cellValue),
'UniversalSortableDateTime',
$.extend({}, $.jgrid.formatter.date, options)
);
} else {
return '';
}
}
}
Note that with custom formatter
you can parse the date and format it in any way you wish. However I did my best to use built-in jqGrid formatting facilities (see the UniversalSortableDateTime
?)
Upvotes: 2