I think it's ideal that the backend send timestamp to the front and it suits you as needed.
Ordering is best to use with timestamp because it is just a number, in Java
will be long
or wrapper
Long
.
Example:
var datasOrdenadas = datasEmTimestamp.sort(function(data1, data2) {
return data1 > data2
});
If you wanted to filter on the front end you can use the power and flexibility of javascript
and its frameworks as the AngularJS
you have commented on, to adjust your objects to your needs .
Example:
Assuming you received timestamp of your webservice
and using AngularJS
.
var datasTratada = datasEmTimestamp.map(function(data) {
var date = new Date(data);
var dataTratada = {
formatada: $filter('date')(data, 'dd/MM/YYYY - HH:mm'),
dia: date.getDate(),
mes: date.getMonth(),
ano: date.getFullYear(),
hora: date.getHours(),
minuto: date.getMinutes()
}
return dataTratada;
});
Already from a list of dates in timestamp
you get a multitude of information about the dates and can work as you want. In the case of AngularJS
, look at the date filter documentation for it, it's very complete: link .
A great library for working with dates in javascript is also moment.js .