集册 Java实例教程 使用日历的before方法比较日期时间

使用日历的before方法比较日期时间

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

543
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用日历的before方法比较日期时间


import java.util.Calendar;

 

public class Main {
/** from 
N o w J a v a . c o m - 时  代  Java**/

 

  public static void main(String[] args) {

    Calendar old = Calendar.getInstance();

   

    old.set(Calendar.YEAR, 1990);

   

    Calendar now = Calendar.getInstance();

     

    System.out.println("Is old before now ? : " + old.before(now));

  }

}