How can I find out the number of days that have passed from the beginning of time (0 year, 1 month, 1 day) to today?
2 answers
A variant that I found here :
Calendar cal = Calendar.getInstance(); cal.set(0, 1, 1); long diff = new Date(System.currentTimeMillis() - cal.getTime().getTime(); System.out.println ("Days: " + TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS)); There is an option with JodaTime :
DateTime date1 = new DateTime(0, 1, 1, 0, 0); DateTime date2 = new DateTime(System.currentTimeMillis()); int days = Days.daysBetween(date1, date2).getDays(); |
Frontal:
int days=System.currentTimeMillis()/(24*60*60*1000L); - one
currentTimeMillisreturns milliseconds not from 0, but from 1970 - andreymal - Of course I know, and what did the vehicle ask for? - Barmaley
|