首页javadateJava Data Type - 如何向LocalDate添加一天,从LocalDateTime减去小时和分钟

Java Data Type - 如何向LocalDate添加一天,从LocalDateTime减去小时和分钟

我们想知道如何向LocalDate添加一天,从LocalDateTime减去小时和分钟。
import java.time.LocalDate;
import java.time.LocalDateTime;

public class Main {
  public static void main(String[] args) {
    LocalDate tomorrow = LocalDate.now().plusDays(1);

    // before 5 hours and 30 minutes
    LocalDateTime dateTime = LocalDateTime.now().minusHours(5).minusMinutes(30);

    System.out.println("additionSubtraction: tomorrow: " + tomorrow);
    System.out.println("additionSubtraction: dateTime: " + dateTime);

  }
}