mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
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:
parent
ad072aaa78
commit
9ce38ae715
@ -2759,7 +2759,14 @@ public abstract class ExchangeSession {
|
|||||||
String value = property.getValue();
|
String value = property.getValue();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
try {
|
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) {
|
} catch (ParseException e) {
|
||||||
LOGGER.warn("Invalid date: " + value);
|
LOGGER.warn("Invalid date: " + value);
|
||||||
}
|
}
|
||||||
|
@ -406,4 +406,21 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
|
|||||||
assertEquals("common & name", contact.get("cn"));
|
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"));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user