Java 日历 Calendar compareTo方法 Java示例-获得主机IP地址1 Java示例-获得主机IP地址2 Java 日历 Calendar compareTo方法 package com.codingdict; import java.util.*; public class CalendarDemo { public static void main(String[] args) { // create two calendar at the different dates Calendar cal1 = new GregorianCalendar(2015, 8, 15); Calendar cal2 = new GregorianCalendar(2008, 1, 02); // compare the time values represented by two calendar objects. int i = cal1.compareTo(cal2); // return positive value if equals else return negative value System.out.println("The result is :"+i); // compare again but with the two calendars swapped int j = cal2.compareTo(cal1); // return positive value if equals else return negative value System.out.println("The result is :" + j); } } Java示例-获得主机IP地址1 Java示例-获得主机IP地址2