I have such a task: There is the date of manufacture of the goods and the date when it will deteriorate. I need to write such a method so that it determines how many percent the int date has expired. That is, for example, the product was manufactured on January 1, it will deteriorate on January 10 and now on January 5, and the method should return 50:
private int realWork() { Calendar createDate = new GregorianCalendar(2016, 0, 1); Calendar expirationDate = new GregorianCalendar(2016, 0, 10); Calendar currentDate = Calendar.getInstance(); // предположим 2016 / 0 / 5 long difference = expirationDate.getTimeInMillis() - createDate.getTimeInMillis(); // а что дальше ума не приложу... } Here is my problem please help.