Java examples for java.util:Date Compare
compare Era
//package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { Calendar calendar = Calendar.getInstance(); Calendar calendar1 = Calendar.getInstance(); System.out.println(compareEra(calendar, calendar1)); }//www.j a v a 2 s .c om public static int compareEra(Calendar calendar, Calendar calendar1) { if (calendar.getClass() != calendar1.getClass()) throw new IllegalArgumentException( "Cannot compare calendars of dissimilar classes: " + calendar + ", " + calendar1); else return calendar.get(Calendar.ERA) - calendar1.get(Calendar.ERA); } }