IMAP: fix search date format for Exchange 2010 support (ErrorInvalidValueForProperty)

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1917 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2012-02-20 23:10:56 +00:00
parent 67766c818f
commit 97c38dc96b
1 changed files with 4 additions and 6 deletions

View File

@ -1297,8 +1297,6 @@ public class ImapConnection extends AbstractConnection {
Date endDate; Date endDate;
SimpleDateFormat parser = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH); SimpleDateFormat parser = new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH);
parser.setTimeZone(ExchangeSession.GMT_TIMEZONE); parser.setTimeZone(ExchangeSession.GMT_TIMEZONE);
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
dateFormatter.setTimeZone(ExchangeSession.GMT_TIMEZONE);
String dateToken = tokens.nextToken(); String dateToken = tokens.nextToken();
try { try {
startDate = parser.parse(dateToken); startDate = parser.parse(dateToken);
@ -1317,12 +1315,12 @@ public class ImapConnection extends AbstractConnection {
} }
if (token.endsWith("ON")) { if (token.endsWith("ON")) {
return session.and(session.gt(searchAttribute, dateFormatter.format(startDate)), return session.and(session.gt(searchAttribute, session.formatSearchDate(startDate)),
session.lt(searchAttribute, dateFormatter.format(endDate))); session.lt(searchAttribute, session.formatSearchDate(endDate)));
} else if (token.endsWith("BEFORE")) { } else if (token.endsWith("BEFORE")) {
return session.lt(searchAttribute, dateFormatter.format(startDate)); return session.lt(searchAttribute, session.formatSearchDate(startDate));
} else if (token.endsWith("SINCE")) { } else if (token.endsWith("SINCE")) {
return session.gte(searchAttribute, dateFormatter.format(startDate)); return session.gte(searchAttribute, session.formatSearchDate(startDate));
} else { } else {
throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", dateToken); throw new DavMailException("EXCEPTION_INVALID_SEARCH_PARAMETERS", dateToken);
} }