Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

public class Main {
    public static boolean isSameDay(Date date1, Date date2) {
        Calendar cal1 = buildFromDate(date1);
        Calendar cal2 = buildFromDate(date2);
        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);
    }

    private static Calendar buildFromDate(Date from) {
        Calendar c = Calendar.getInstance();
        c.setTime(from);
        return c;
    }
}