Here you can find the source of compareInSameDay(Date date1, Date date2)
Parameter | Description |
---|---|
date1 | a parameter |
date2 | a parameter |
public static boolean compareInSameDay(Date date1, Date date2)
//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); } }