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;

public class Main {
    private static ThreadLocal<Calendar> calendarThreadLocal = new ThreadLocal<Calendar>();

    public static boolean areSameDays(long time1, long time2) {
        Calendar calendar = calendarThreadLocal.get();
        if (calendar == null) {
            calendar = Calendar.getInstance();
            calendarThreadLocal.set(calendar);
        }
        calendar.setTimeInMillis(time1 * 1000L);
        int y1 = calendar.get(Calendar.YEAR);
        int m1 = calendar.get(Calendar.MONTH);
        int d1 = calendar.get(Calendar.DATE);
        calendar.setTimeInMillis(time2 * 1000L);
        int y2 = calendar.get(Calendar.YEAR);
        int m2 = calendar.get(Calendar.MONTH);
        int d2 = calendar.get(Calendar.DATE);

        return y1 == y2 && m1 == m2 && d1 == d2;
        // return (time1 / (60 * 60 * 24)) == (time2 / (60 * 60 * 24));
    }
}