To calculate the number of days between two dates in Java, you can use the Period class from the java.time package introduced in Java 8.