1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-12 04:25:08 -05:00

Fixes Issue 448

Fixes Issue 651
This commit is contained in:
Daniel Applebaum 2009-10-28 12:45:22 +00:00
parent 25e36da75d
commit 8951363442

View File

@ -22,6 +22,9 @@ import com.android.email.mail.MessagingException;
public class ImapResponseParser {
SimpleDateFormat mDateTimeFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z", Locale.US);
SimpleDateFormat badDateTimeFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z", Locale.US);
PeekableInputStream mIn;
InputStream mActiveLiteral;
@ -208,7 +211,7 @@ public class ImapResponseParser {
// contain
// * and some falgs contain *
// ch == '%' || ch == '*' ||
ch == '%' ||
// ch == '%' ||
// TODO probably should not allow \ and should recognize
// it as a flag instead
// ch == '"' || ch == '\' ||
@ -301,7 +304,7 @@ public class ImapResponseParser {
public Date getDate(int index) throws MessagingException {
try {
return mDateTimeFormat.parse(getString(index));
return parseDate(getString(index));
} catch (ParseException pe) {
throw new MessagingException("Unable to parse IMAP datetime", pe);
}
@ -338,11 +341,31 @@ public class ImapResponseParser {
if (value == null) {
return null;
}
return mDateTimeFormat.parse(value);
return parseDate(value);
} catch (ParseException pe) {
throw new MessagingException("Unable to parse IMAP datetime", pe);
}
}
private Date parseDate(String value) throws ParseException
{
try
{
synchronized(mDateTimeFormat)
{
return mDateTimeFormat.parse(value);
}
}
catch (Exception e)
{
synchronized(badDateTimeFormat)
{
return badDateTimeFormat.parse(value);
}
}
}
}
/**