Is it possible to adjust the JavaScript Date
string value to format of java.sql.Time
. I can't seem to find a correct solution for this.
Thanks!
Is it possible to adjust the JavaScript Date
string value to format of java.sql.Time
. I can't seem to find a correct solution for this.
Thanks!
You should serialize you object on server side:
es. @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss.sssZ")
and then on the client side you could use moment.js:
moment(stringDate, 'yyyy-MM-dd'T'HH:mm:ss.sssZ').toDate();
this is how to convert to sql date format
var date;
date = new Date();
date = date.getUTCFullYear() + '-' +
('00' + (date.getUTCMonth() + 1)).slice(-2) + '-' +
('00' + date.getUTCDate()).slice(-2) + ' ' +
('00' + date.getUTCHours()).slice(-2) + ':' +
('00' + date.getUTCMinutes()).slice(-2) + ':' +
('00' + date.getUTCSeconds()).slice(-2);