I have an android app in which i want to convert my string into date data type.
I get the string via date picker in this format (“12/30/2011”).
I want to convert it into string in the same format. This is my code:
Date dateObj = new Date();
dateFormat = new SimpleDateFormat("MM/dd/yyyy");
dateFormat.setLenient(false);
dateObj = dateFormat.parse("12/30/2011");
Log.v("",""+dateObj);
But i get value in this form:
Wed Dec 28 00:00:00 GMT+05:00 2011
Does it help?
Please have a look at this
Output: 12/28/2011
In place of
use this
You shouldn’t print the original date object but the formatted one.