I have the following string: dateToParse = "Fri May 16 23:59:59 BRT 2014"
, and want to parse it using DateFormat:
DateFormat dateFormat = new SimpleDateFormat(pattern, Locale.getDefault());
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
cal.setTime(dateFormat.parse(dateToParse));
right now I'm trying it with pattern = "EEE MMM dd HH:mm:ss z yyyy"
, but get this exception:
java.text.ParseException: Unparseable date: "Fri May 16 23:59:59 BRT 2014" (at offset 0)
I can't figure out what's wrong with this pattern, specially at index 0... any idea what am I missing? Thanks.
[EDIT] So part of the problem was I was using Locale.getDefault(), so problably trying to parse a date in english with a dateFormat in portuguese... with the correct Locale, I'm still getting ParseException, but this time at offset 20, which means something is going wrong when parsing the timezone ('BRT', in my case)...