1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-10-31 15:45:08 -04:00

Unify two IMAP date parsing paths, improving the exception so we can

learn what date format we don't cope with.
This commit is contained in:
Jesse Vincent 2011-04-03 14:18:15 +09:30
parent 65c6fe592e
commit 39e3aecf73

View File

@ -347,13 +347,25 @@ public class ImapResponseParser {
}
public Date getDate(int index) throws MessagingException {
return getDate(getString(index));
}
public Date getKeyedDate(Object key) throws MessagingException {
return getDate(getKeyedString(key));
}
private Date getDate(String value) throws MessagingException {
try {
return parseDate(getString(index));
if (value == null) {
return null;
}
return parseDate(value);
} catch (ParseException pe) {
throw new MessagingException("Unable to parse IMAP datetime", pe);
throw new MessagingException("Unable to parse IMAP datetime '"+value+"' ", pe);
}
}
public Object getKeyedValue(Object key) {
for (int i = 0, count = size(); i < count; i++) {
if (equalsIgnoreCase(get(i), key)) {
@ -379,18 +391,6 @@ public class ImapResponseParser {
return Integer.parseInt(getKeyedString(key));
}
public Date getKeyedDate(Object key) throws MessagingException {
try {
String value = getKeyedString(key);
if (value == null) {
return null;
}
return parseDate(value);
} catch (ParseException pe) {
throw new MessagingException("Unable to parse IMAP datetime", pe);
}
}
public boolean containsKey(Object key) {
if (key == null) {
return false;