🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Date and Time in Java: all 10 questions

Quiz: Date and Time in Java · Question 4 of 10

You need the total number of days from today until an exam. Which is correct?

You need the total number of days from today until an exam. Which is correct?

  1. A.Period.between(today, exam).getDays()
  2. B.ChronoUnit.DAYS.between(today, exam)
  3. C.Duration.between(today, exam).toDays() on two LocalDate values
  4. D.exam.getDayOfMonth() - today.getDayOfMonth()
Answer & explanation

Correct answer: ChronoUnit.DAYS.between(today, exam)

Period.getDays gives only the days part (ignoring months); ChronoUnit.DAYS.between gives the full count.

Can you get the rest right without peeking?

Take the timed Quiz: Date and Time in Java quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →