提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
要比较两个不同的日历对象,请使用boolean after(Calendar anotherCal)方法。
import java.util.Calendar; /**来自 nowjava - 时代Java**/ public class Main { public static void main(String[] args) { Calendar futureCal = Calendar.getInstance(); futureCal.set(Calendar.YEAR, 2017); Calendar now = Calendar.getInstance(); System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.DATE) + "-" + now.get(