diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 0b0d1dbc..20142772 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -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); } diff --git a/src/test/davmail/exchange/TestExchangeSessionContact.java b/src/test/davmail/exchange/TestExchangeSessionContact.java index 2da8c6d0..7979f1a7 100644 --- a/src/test/davmail/exchange/TestExchangeSessionContact.java +++ b/src/test/davmail/exchange/TestExchangeSessionContact.java @@ -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")); + + } }