Java Calendar Compare isSameInstant(Calendar cal1, Calendar cal2)

Here you can find the source of isSameInstant(Calendar cal1, Calendar cal2)

Description

is Same Instant

License

Apache License

Declaration

public static boolean isSameInstant(Calendar cal1, Calendar cal2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static boolean isSameInstant(Date date1, Date date2) {
        if (date1 == null || date2 == null) {
            throw new IllegalArgumentException("The date must not be null");
        }/*from w w w.  j  av  a2  s  .  c  om*/
        return date1.getTime() == date2.getTime();
    }

    public static boolean isSameInstant(Calendar cal1, Calendar cal2) {
        if (cal1 == null || cal2 == null) {
            throw new IllegalArgumentException("The date must not be null");
        }
        return cal1.getTime().getTime() == cal2.getTime().getTime();
    }
}

Related

  1. isEqual(Calendar calendar, Date date)
  2. isEquals(Calendar sourceDate, Calendar compareDate)
  3. isSameDate(Calendar d1, Calendar d2)
  4. isSameDate(java.util.Calendar date1, java.util.Calendar date2)
  5. isSameInstant(Calendar cal1, Calendar cal2)
  6. isSameInstant(Calendar cal1, Calendar cal2)
  7. isSameInstant(final Calendar cal1, final Calendar cal2)
  8. max(Calendar cal1, Calendar cal2)
  9. min(Calendar c1, Calendar c2)