0

I am trying to subtract the Inserted date and the current date. The inserted date already in the format dd/mm/yyyy in SQLite.

Here is my coding

Calendar today = Calendar.getInstance();
    String inDate = EventListAdapter.KEY_DATE;
    DateFormat formatter ; 
    Date insertDate ; 
    formatter = new SimpleDateFormat("dd/MM/yyyy");
    insertDate = formatter.parse(inDate);

    long diff = insertDate.getTime() - today.getTimeInMillis();
    dayLeft = (int) (diff / (24 * 60 * 60 * 1000));

The insertDate is taken from the SQLite.

And then there is still get error in the problem there.

Description Resource    Path    Location    Type
Unhandled exception type ParseException {my project path}line 46    Java Problem
user2274349
  • 415
  • 2
  • 5
  • 12

0 Answers0