Moatez Bouhdid Moatez Bouhdid - 2 months ago 25
AngularJS Question

Java 8 LocalDate to JavaScript Date

I would like to convert this Java

to a JavaScript

"date": {
"year": 2016,
"month": "NOVEMBER",
"dayOfMonth": 15,
"monthValue": 11,
"dayOfWeek": "TUESDAY",
"era": "CE",
"dayOfYear": 320,
"leapYear": true,
"chronology": {
"id": "ISO",
"calendarType": "iso8601"


Your date string does not specify a time zone. You are also missing time information, while JavaScript dates store the time of day by design.

Your string is nearly valid JSON, so you can parse it via JSON.parse(). It is only missing one closing } bracket.

Considering the remarks above, you could use the following approach:

var input = JSON.parse('{"date":{"year":2016,"month":"NOVEMBER","dayOfMonth":15,"monthValue":11,"dayOfWeek":"TUESDAY","era":"CE","dayOfYear":320,"leapYear":true,"chronology":{"id":"ISO","calendarType":"iso8601"}}}');
var day =;
var month = - 1; // Month is 0-indexed
var year =;

var date = new Date(Date.UTC(year, month, day));

console.log(date); // "2016-11-15T00:00:00.000Z"