I am new to Java, usually work with PHP.
I am trying to convert this string:
Mon Mar 14 16:02:37 GMT 2011
Into a Calendar Object so that I can easily pull the Year and Month like this:
String yearAndMonth = cal.get(Calendar.YEAR)+cal.get(Calendar.MONTH);
Would it be a bad idea to parse it manually? Using a substring method?
Any advice would help thanks!
No new Calendar needs to be created, SimpleDateFormat already uses a Calendar underneath.
(I can't comment yet, that's why I created a new answer)
note: set
Locale
according to your environment/requirementSee Also