0

Iam returning a Map from java to the angular controller.

java code:

Below is the sample object i'm returning to js code..

  Map<String, Object> data = new HashMap<String, Object>();
   //Timestamp ts1  = ...;//some date here
  // Timestamp ts2  = ..;//date
   data.put("startDate",ts1);
   data.put("endDate",ts2);
   return data;

I have a object in my angularjs controller which has date stored in it:

    console.log("Date is " + $scope.myResponse.startDate);//[object object]
 console.log("EndDate is " + $scope.myResponse.endDate);//[object object]

How to get the date value from the above response object instead of [object object]..

user222
  • 587
  • 3
  • 10
  • 31
  • Does this help? https://stackoverflow.com/questions/20131553/angularjs-convert-dates-in-controller – bp4D Feb 14 '18 at 22:16
  • What is the result of `console.log("Date is " + JSON.stringify($scope.myResponse.startDate));`? – sliptype Feb 14 '18 at 22:16

1 Answers1

0

You can return the time in millis

     Map<String, Object> data = new HashMap<String, Object>();
   //Timestamp ts1  = ...;//some date here
  // Timestamp ts2  = ..;//date
   data.put("startDate",ts1.getTime());
   data.put("endDate",ts2.getTime());
   return data;
Brandon Kearby
  • 603
  • 7
  • 8