java - Date Conversion in Spring is one day off -
i have post end-point takes couple of values, 1 being enddate , startdate. when json posts in as:
{ "startdate" : "2015-01-30", "enddate" : "2015-12-30" }
spring converts java.util.date object 1 day behind. in logs see:
validating startdate thu jan 29 16:00:00 pst 2015 < enddate tue dec 29 16:00:00 pst 2015
so got timezone correct. had assumed related utc conversions, i'm not sure how configure or modify converts using proper off-set. timestamp portion of isn't required - care year, day, , month match passed in.
if matters, i'm using spring (happened 4.0.6 , 4.1.7) , post
string str="2015-01-30"; try{ simpledateformat isoformat = new simpledateformat("yyyy-mm-dd"); isoformat.settimezone(timezone.gettimezone("pst")); date date = isoformat.parse(str); system.out.println(date); }catch(parseexception e){ e.printstacktrace(); }
Comments
Post a Comment