mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05: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:
parent
65c6fe592e
commit
39e3aecf73
@ -347,13 +347,25 @@ public class ImapResponseParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Date getDate(int index) throws MessagingException {
|
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 {
|
try {
|
||||||
return parseDate(getString(index));
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return parseDate(value);
|
||||||
} catch (ParseException pe) {
|
} 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) {
|
public Object getKeyedValue(Object key) {
|
||||||
for (int i = 0, count = size(); i < count; i++) {
|
for (int i = 0, count = size(); i < count; i++) {
|
||||||
if (equalsIgnoreCase(get(i), key)) {
|
if (equalsIgnoreCase(get(i), key)) {
|
||||||
@ -379,18 +391,6 @@ public class ImapResponseParser {
|
|||||||
return Integer.parseInt(getKeyedString(key));
|
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) {
|
public boolean containsKey(Object key) {
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user