Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import org.joda.time.DateTime;

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

public class Main {
    public static boolean sameDay(DateTime then, DateTime now) {
        if (then == null || now == null) {
            return false;
        }
        return sameDay(then.toDate(), now.toDate());
    }

    public static boolean sameDay(Date then, Date now) {

        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        cal1.setTime(then);
        cal2.setTime(now);

        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR);

    }
}