集册 Java实例教程 找出两次约会之间的年份和日期

找出两次约会之间的年份和日期

欢马劈雪     最近更新时间:2020-01-02 10:19:05

541
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
找出两次约会之间的年份和日期

import java.time.LocalDate;

import java.time.Month;

import java.time.temporal.ChronoUnit;
/*来 自 时代Java - N o w  J a v a . c o m*/

public class Main {


  public static void main(String[] args) {

    LocalDate anniversary = LocalDate.of(2000, Month.NOVEMBER, 11);

    LocalDate today = LocalDate.now();

    long yearsBetween = ChronoUnit.YEARS.between(anniversary, today);

    System.out.println("Years between dates: " + yearsBetween);


    long daysBetween = 
展开阅读全文