Reputation: 2454
I am trying to format this date to output something like Mon Feb 12,2008
try {
date = new SimpleDateFormat("MM/dd/yyyy").parse("02/12/2008").toString();
} catch (ParseException e) {
Log.v(TAG,e.getMessage());
}
String dateParsed = new SimpleDateFormat("EEE MMM/dd/yyyy").format(date);
I am getting an illegal argument exception.
Upvotes: 1
Views: 718
Reputation: 285430
You're appear to be trying to set a Date = to a String:
date = new SimpleDateFormat("MM/dd/yyyy").parse("02/12/2008").toString();
and that will never work.
If the date variable is actually a String variable, then that won't work either, since you'll be trying to call SimpleDateFormat#format(...)
with a String parameter, and it requires a Date object.
Instead be sure that the date variable is in fact a Date
variable, parse the String into a Date object, assign it to date (and don't call toString()
on it), and then format the date variable after you've got it.
Upvotes: 2