In order to parse a String into a Date
which contains certains words (e.g. for the month), then you need an appropriate Locale
corresponding to the language of these words. Since they are in english in your example you could use a language specific locale like java.util.Locale.ENGLISH
or a country specific one, like java.util.Locale.US
or Locale.UK
.
Since you can pass the Locale
to the SimpleDateFormat
constructor your instantiation could look like this:
SimpleDateFormat curFormater = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ssZ", Locale.ENGLISH);
If you like to know the allowed date format words in your currently used Locale
, then you can try the following snippet, which uses the DateFormatSymbols
class:
DateFormatSymbols dfs = new DateFormatSymbols();
System.out.println(Arrays.toString(dfs.getShortMonths()));
This class provides corresponding methods to get months, the abbreviated months or the weekdays.
You can also pass a Locale
to the DateFormatSymbols
constructor to get these strings from the specific locale.