Java Day of Month isSameDayOfMonth(Date dt1, Date dt2)

Here you can find the source of isSameDayOfMonth(Date dt1, Date dt2)

Description

Does it have the same day of month

License

Open Source License

Parameter

Parameter Description
dt1 a parameter
dt2 a parameter

Declaration

public static boolean isSameDayOfMonth(Date dt1, Date dt2) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**//  w w w.  j  a  v  a  2 s  .com
     * Does it have the same day of month
     * @param dt1
     * @param dt2
     * @return
     */
    public static boolean isSameDayOfMonth(Date dt1, Date dt2) {
        if (dt1 == null || dt2 == null)
            return false;
        GregorianCalendar gc1 = new GregorianCalendar();
        gc1.setTime(dt1);
        GregorianCalendar gc2 = new GregorianCalendar();
        gc2.setTime(dt2);

        return (gc1.get(Calendar.DAY_OF_MONTH) == gc2.get(Calendar.DAY_OF_MONTH));
    }
}

Related

  1. getLastDayOfXMonth(Date date, String xMonth)
  2. getToDate(boolean invoiceSearchFromFirstDayOfMonth)
  3. getWeekOfFirstDayOfMonth(Date date)
  4. getWeekOfLastDayOfMonth(Date date)
  5. isGivenDayOfMonth(java.util.Date date, int dayOfMonth)
  6. newDate(int year, int month, int dayOfMonth)
  7. setDayOfMonth(Date d, int date)
  8. toDate(final int year, final int month, final int dayOfMonth)