Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;

public class Main {
    /**
     * if two date is the same day, for example ,1999-11-21 00:00:00 and  1999-11-21 23:15:40 are in same day,
     * but 1999-11-21 00:00:00 and 2010-11-21 00:00:00 are not
     *
     * @param ltime
     * @param rtime
     * @return
     */
    public static boolean sameDay(long ltime, long rtime) {
        Calendar l = Calendar.getInstance();
        Calendar r = Calendar.getInstance();
        l.setTimeInMillis(ltime);
        r.setTimeInMillis(rtime);

        return l.get(Calendar.YEAR) == r.get(Calendar.YEAR) && l.get(Calendar.MONTH) == r.get(Calendar.MONTH)
                && l.get(Calendar.DAY_OF_MONTH) == r.get(Calendar.DAY_OF_MONTH);
    }
}