Java Day Compare compareInSameDay(Date date1, Date date2)

Here you can find the source of compareInSameDay(Date date1, Date date2)

Description

compare In Same Day

License

Open Source License

Parameter

Parameter Description
date1 a parameter
date2 a parameter

Return

boolean

Declaration

public static boolean compareInSameDay(Date date1, Date date2) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String format1 = "yyyy-MM-dd";

    public static boolean compareInSameDay(Date date1, Date date2) {
        if (null == date1 || null == date2)
            return false;
        String dateString1 = getFormateDateString(date1, format1);
        String dateString2 = getFormateDateString(date2, format1);
        if (dateString1.equals(dateString2)) {
            return true;
        }/*from  www  .j  a v a  2 s  .  c om*/
        return false;
    }

    public static String getFormateDateString(Date date, String format) {
        if (date == null)
            return null;
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        return dateFormat.format(date);
    }
}

Related

  1. afterNDay(int n)
  2. afterNDaysDate(String theDate, int nDayNum, String format)
  3. compareDateByDay(Date date1, Date date2)
  4. compareDay(Date first, Date second)
  5. isSameDay(Date a, Date b)
  6. isSameDay(Date c1, Date c2)
  7. isSameDay(Date date, Date date2)
  8. isSameDay(Date date1, Date date2)