String date = jsonobject.getString("needbydate");
DateFormat df = new SimpleDateFormat("MMM/dd/yyyy");
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ");
Date startDate = sdf.parse(date);
String needbydate = df.format(startDate).toString()+"";
What is happening::
- At the start
date=2014-12-17T21:37:00+00:00
- At the end
needbydate= Dec/18/2014
17 is changed to 18 .... What wrong am i doing in conversion
EDIT:
String date=jsonobject.getString("needbydate");
DateFormat df = new SimpleDateFormat("MMM/dd/yyyy",Locale.ENGLISH);
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss",Locale.ENGLISH);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date startDate;
startDate = sdf.parse(date);
needbydate = df.format(startDate).toString()+"";
HHinstead ofhh? Capital h is for the 24hours formatZon the SDF as it is causing an Unparseable date exception.