java - Getting ArrayIndexOutOfBoundsException on Sorting list taken from SharedInstance in Android -
i have list stored in sharedinstance, want sort based upon time parameter.
code sorting collections.sort(sharedinstance.getinstance().getmasterlistfavfeeds().getposts(), new datecomparator());
public class datecomparator implements comparator { dateformat dateformat = new simpledateformat("yyyy-mm-dd't'hh:mm:ss");
@override public int compare(object date1, object date2) { try { return dateformat.parse(date2.tostring()).compareto(dateformat.parse(date1.tostring())); } catch (parseexception e) { throw new illegalargumentexception(e); } }
}
crash log
java.lang.arrayindexoutofboundsexception: length=1459; index=1459 @ java.util.collections.sort(collections.java:1888) @ com.fnshealth_android.utils.updatecomments.updatecommentcounttosharedinstancelist(updatecomments.java:34) @ com.fnshealth_android.utils.notificationmanager.processnewcommentfeed(notificationmanager.java:135) @ com.fnshealth_android.utils.notificationmanager.setdatamessagesmap(notificationmanager.java:99) @ com.fnshealth_android.services.fnsfirebasemessagingservice.onmessagereceived(fnsfirebasemessagingservice.java:46) @ com.google.firebase.messaging.firebasemessagingservice.zzo(unknown source) @ com.google.firebase.messaging.firebasemessagingservice.zzn(unknown source) @ com.google.firebase.messaging.firebasemessagingservice.zzm(unknown source) @ com.google.firebase.iid.zzb$2.run(unknown source) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1112) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:587) @ java.lang.thread.run(thread.java:818)
why getting such crash ? , how handle ?
can use try catch arryaoutofindex exception ?
Comments
Post a Comment