while running below java code
string v_date_str = "03/04/2015"; date v_date = new simpledateformat("mm/dd/yyyy").parse(v_date_str); dateformat formatter = null; formatter = new simpledateformat("dd-mmm-yyyy"); date date_temp = null; date_temp = (date) formatter.parse("31-dec-2012"); // string of same format formatter out.println("output: " + formatter.format(v_date)); i expecting output below.
output: 03-mar-2015 but getting output
output: 28-dec-2014 please let me know going wrong , how can fix this.
thanks
you parsing date wrong format. d day in year, not day in month, d. y week year, not year, y. once fix format, code executes expect:
date v_date = new simpledateformat("mm/dd/yyyy").parse(v_date_str);
Comments
Post a Comment