I am trying to format a date such as Mon Jul 28 00:00:00 CDT 2014
to something a bit more user friendly, such as Mon 6/28
. What am I doing wrong?
Code:
String date_string = "Mon Jul 28 00:00:00 CDT 2014";
SimpleDateFormat inputFormatter = new SimpleDateFormat("ccc LLL F HH:mm:ss zzz yyyy"); //please notice the capital M
SimpleDateFormat outputFormatter = new SimpleDateFormat("ccc LLL/yyyy");
try {
Date date = inputFormatter.parse(date_string);
String text = outputFormatter.format(date);
System.out.println(text);
} catch (ParseException e) {
e.printStackTrace();
}
When I use System.out.println to see what outputFormatter is set to, the result is: Sun Jan/2015