I have the following line: 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));
I'm trying with help right now pattern = "EEE MMM dd HH:mm:ss z yyyy", but getting this exception:
java.text.ParseException: Unparseable date: "Fri May 16 23:59:59 BRT 2014" (at offset 0)
I can’t understand what is wrong with this pattern, especially at index 0 ... any idea what I am missing? Thank.
[EDIT] So part of the problem was that I used Locale.getDefault (), so probably trying to parse a date in English using dateFormat in Portuguese ... with the correct Locale, I still get ParseException, but for this times with an offset of 20, which means that something happens wrong when analyzing the time zone ("BRT", in my case) ...
source
share