I use CST time on my system, starting from front-end through javascript. I am sending a date today to the spring controller. In the spring controller, through the request parameter, I get the date and convert to date through the @DateTimeFormat annotation, and I get the same date back to the view. I get the exact date I expect.
But, when I test my test environment, which is deployed on amazon server. When I pass today's date, and when I try to get the same date in the foreground, it fits like another date. I wrote the code that I used.
JavaScript:
$http({ method : 'GET', url : urlpath + '/getDate/', params: { date: new Date().toString("MM/dd/yyyy") } }).success(function(response) { console.log("date is"+response) }
Java Code:
@RequestMapping(value = "/getdate", method = RequestMethod.GET) public Date getdate(@RequestParam("date") @DateTimeFormat(pattern ="MM/dd/yyyy") throws Exception { return date; }
Date on my local machine 01-05-2015 23:17 Console expression: Fri May 1, 2015 00:00:00 GMT-0500 (Central Daylight Time) no hh mm and ss since I cropped using the datetimeformat annotation.
In my test environment, I use the same code, but the console is attractive, as shown below. Thu Apr 30 2015 23:00:00 GMT-0500 (Central Daylight Saving Time)
Can anyone solve this problem and tell me the reason for this problem.
source share