Java Day Compare isSameDay(Date date1, Date date2)

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

Description

is Same Day

License

Open Source License

Declaration

public static boolean isSameDay(Date date1, Date date2) 

Method Source Code


//package com.java2s;

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.*;

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

    public static boolean isSameDay(Date date1, Date date2) {
        DateFormat fmt = getFormat(dateFormat);
        return fmt.format(date1).equals(fmt.format(date2));
    }/*  ww w  . j a  v  a 2s  . c o  m*/

    public static final DateFormat getFormat(String format) {
        return new SimpleDateFormat(format);
    }

    public static final String format(Date date, String formate) {
        if (date == null) {
            return "";
        }
        return getFormat(formate).format(date);
    }

    public static final String format(Long dateTmie, String formate) {
        Date date = new Date(dateTmie);
        return getFormat(formate).format(date);
    }
}

Related

  1. compareInSameDay(Date date1, Date date2)
  2. isSameDay(Date a, Date b)
  3. isSameDay(Date c1, Date c2)
  4. isSameDay(Date date, Date date2)
  5. isSameDay(Date date1, Date date2)
  6. isSameDay(Date date1, Date date2)
  7. isSameDay(Date date1, Date date2)
  8. isSameDay(Date date1, Date date2)
  9. isSameDay(Date date1, Date date2)