Java Date Equal isEqualField(int field, Date d1, Date d2)

Here you can find the source of isEqualField(int field, Date d1, Date d2)

Description

is Equal Field

License

Open Source License

Declaration

public static boolean isEqualField(int field, Date d1, Date d2) 

Method Source Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static boolean isEqualField(int field, Date d1, Date d2) {
        Calendar c1 = Calendar.getInstance();
        c1.setTime(d1);/*  w w w .ja v a  2s  .com*/

        Calendar c2 = Calendar.getInstance();
        c2.setTime(d2);
        return c1.get(field) == c2.get(field);
    }

    public static int get(int field, Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.get(field);
    }
}

Related

  1. firstLessOrEqualSecond(Date firstDate, Date secondDate)
  2. hourEqual(Date date1, Date date2)
  3. isEqual(Date date1, Date date2)
  4. isEqualByDay(Date date1, Date date2)
  5. isEqualDate(Date date1, Date date2)
  6. isLowerEqualDate(Date date)
  7. isSameDate(Date date, Date date1)
  8. isSameDate(Date date1, Date date2)
  9. isSameDate(Date pathDate, Date now)