NumberFormatException
For input string: "28\2\1986"
java.lang.Integer in parseInt at line 521
java.lang.Integer in parseInt at line 556
com.rt2zz.reactnativecontacts.ContactsProvider in loadContactsFrom at line 268
com.rt2zz.reactnativecontacts.ContactsProvider in getContacts at line 141
com.rt2zz.reactnativecontacts.ContactsManager$1 in run at line 79
android.os.AsyncTask$SerialExecutor$1 in run at line 243
java.util.concurrent.ThreadPoolExecutor in runWorker at line 1133
java.util.concurrent.ThreadPoolExecutor$Worker in run at line 607
java.lang.Thread in run at line 762
I believe this is a new exception from version: 2.1.3
Issue is that it assumes a certain localization to assign a Birthday (https://github.com/rt2zz/react-native-contacts/blob/master/android/src/main/java/com/rt2zz/reactnativecontacts/ContactsProvider.java#L264).
Above one uses day\month\year, but I've got crashes with 09 Jan 1984 for example.
It looks like in iOS we get it back as a typed NSDateComponents so this is not an issue there.
I'm not too familiar with Java to be able to fix, for example in C# this'd be ideally be done through
c#
if(DateTime.TryParse(birthday, out DateTime typedBirthday)
{
contact.birthday = new Contact.Birthday(typedBirthday.Year, typedBirthday.Month, typedBirthday.Day);
}
If someone knows the Java equivalent I'd be happy to submit a pull request.
Also getting reports of crashes on iOS related to contacts since updating to last version, but sadly no stack traces available.
having this crash too on version 2.1.2
@janpieterz is correct. I'll take a look at this today!
For now I will just add try/catch to solve the crash. But this means only contacts with birthdays in the format "1986-12-30" or "12-30" will have their birthdays imported. It is likely possible to do smarter date format detection and parsing but this is all I have time for right now.
Sorry @morenoh149 but that won't compile... pls stand by for fix
Most helpful comment
For now I will just add try/catch to solve the crash. But this means only contacts with birthdays in the format "1986-12-30" or "12-30" will have their birthdays imported. It is likely possible to do smarter date format detection and parsing but this is all I have time for right now.