From 0c1da53df62ff0b31f5c6add353168d1612d320d Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 29 Nov 2018 21:30:51 +0100 Subject: [PATCH] fix #312, make birthday parsing more robust --- .../contacts/pro/helpers/VcfImporter.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt index fe08741a..290327c1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt @@ -14,8 +14,6 @@ import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.* import com.simplemobiletools.contacts.pro.models.* import ezvcard.Ezvcard import ezvcard.VCard -import org.joda.time.DateTime -import org.joda.time.format.DateTimeFormat import java.io.File import java.io.FileOutputStream import java.net.URLDecoder @@ -26,8 +24,6 @@ class VcfImporter(val activity: SimpleActivity) { IMPORT_FAIL, IMPORT_OK, IMPORT_PARTIAL } - private val PATTERN = "EEE MMM dd HH:mm:ss 'GMT'ZZ YYYY" - private var contactsImported = 0 private var contactsFailed = 0 @@ -160,8 +156,10 @@ class VcfImporter(val activity: SimpleActivity) { } private fun formatDateToDayCode(date: Date): String { - val dateTime = DateTime.parse(date.toString(), DateTimeFormat.forPattern(PATTERN)) - return dateTime.toString("yyyy-MM-dd") + val year = 1900 + date.year + val month = String.format("%02d", date.month + 1) + val day = String.format("%02d", date.date) + return "$year-$month-$day" } private fun getContactGroups(ezContact: VCard): ArrayList {