Carddav: fix iPhone BDAY parser

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1233 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-20 15:23:12 +00:00
parent ad072aaa78
commit 9ce38ae715
2 changed files with 26 additions and 2 deletions

View File

@ -921,7 +921,7 @@ public abstract class ExchangeSession {
// check Sent folder for duplicates
ExchangeSession.MessageList messages = searchMessages(SENT, headerEquals("message-id", mimeMessage.getMessageID()));
if (!messages.isEmpty()) {
LOGGER.debug("Dropping message id "+mimeMessage.getMessageID()+": already sent");
LOGGER.debug("Dropping message id " + mimeMessage.getMessageID() + ": already sent");
} else {
// Exchange 2007 : skip From: header
mimeMessage.removeHeader("from");
@ -2759,7 +2759,14 @@ public abstract class ExchangeSession {
String value = property.getValue();
if (value != null) {
try {
properties.put("bday", ExchangeSession.getExchangeZuluDateFormatMillisecond().format(ExchangeSession.getZuluDateFormat().parse(value)));
SimpleDateFormat parser;
if (value.length() == 10) {
parser = new SimpleDateFormat("yyyy-MM-dd");
parser.setTimeZone(GMT_TIMEZONE);
} else {
parser = ExchangeSession.getZuluDateFormat();
}
properties.put("bday", ExchangeSession.getExchangeZuluDateFormatMillisecond().format(parser.parse(value)));
} catch (ParseException e) {
LOGGER.warn("Invalid date: " + value);
}

View File

@ -406,4 +406,21 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
assertEquals("common & name", contact.get("cn"));
}
public void testDateValue() throws IOException {
ExchangeSession.Contact contact = getCurrentContact();
VCardWriter vCardWriter = new VCardWriter();
vCardWriter.startCard();
vCardWriter.appendProperty("BDAY", "2000-01-02");
vCardWriter.endCard();
ExchangeSession.ItemResult result = session.createOrUpdateContact("testcontactfolder", itemName, vCardWriter.toString(), contact.etag, null);
assertEquals(200, result.status);
contact = getCurrentContact();
assertEquals("20000102T000000Z", contact.get("bday"));
}
}