I know It's very known and easy solution for the issue that I'm going to describe here. I'm trying to parse following date format but getting parse exception only even if passing right format to parse that String.
try{
String mDateFormat = "Tue Nov 03 13:46:28 GST 2015";
SimpleDateFormat mFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
Date mFormattedDate = mFormat.parse(mDateFormat);
}catch(ParseException e){
e.printStackTrace();
}
Timezone included with this String is throwing crash only. If I will remove it, It's able to parse it properly. So Something is wrong with timezone format but Even I tried the standards declared by this link : SimpleDateFormat By Developer Site
Anyone suggest me what's wrong here?
Thanks,
What I did as easy solution :
1) Separate Timezone as String from the below format and replace with "" :
String mDateFormat = "Tue Nov 03 13:46:28 GST 2015";
String mTimeZone = mDateFormat.substring(20,23);
String mActualDate = mDateFormat.replace(mTimeZone + " ", "");
2) Get the default Timezone and Set the same one while applying SimpleDateFormat
final String TWITTER = "EEE MMM dd HH:mm:ss yyyy";
SimpleDateFormat mSf = new SimpleDateFormat(TWITTER, Locale.ENGLISH);
mSf.setTimeZone(TimeZone.getDefault());
Date mNewDate = sf.parse(mActualDate);
3) Get the updated date with same Timezone. No need to convert with GMT stuff.