4
In a java program, where the person first inserts the day, then the month, then the year, how do I know how many days passed from that date inserted until another later date that will also be informed by the person? For example: First date informed: 20/10/1990 Second date notified: 23/05/2005 How do I know the total amount of days that have passed?
Good. I forgot to say, for Java 5 or higher we have the library Joda-Time. With it the code shortens to
Days.between(begin, end).getDays()
.– Anthony Accioly
We can also use Timeunit to avoid manual conversions:
TimeUnit.DAYS.convert(diferencaEmMilisegundos, TimeUnit.MILLISECONDS)
.– Anthony Accioly
Joda-time proceeds! Now Timeunit only from Java 5, and Constant DAYS only from Java 6 :)
– wryel