ChronoUnit contains the following constants to represent units of time:
import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; public class Main { public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); // Get the date time 4 days ago LocalDateTime ldt2 = now.minus(4, ChronoUnit.DAYS); System.out.println("Current Datetime: " + now); System.out.println("4 days ago: " + ldt2); }/* w w w . j av a2 s .c o m*/ }