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?

  • 0 year does not exist in the Gregorian and Yulina calendars, after 1 year BC, immediately goes 1 year of our era. Specify exactly what “0 year” you need? - andreymal

2 answers 2

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
      currentTimeMillis returns milliseconds not from 0, but from 1970 - andreymal
    • Of course I know, and what did the vehicle ask for? - Barmaley