Java Today isToday(long milliseconds)

Here you can find the source of isToday(long milliseconds)

Description

is Today

License

Apache License

Declaration

public static boolean isToday(long milliseconds) 

Method Source Code

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

import java.util.Calendar;

public class Main {

    public static boolean isToday(long milliseconds) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(milliseconds);
        if (getCurrentMonth() == getMonth(milliseconds) && getCurrentDay() == getDay(milliseconds)) {
            return true;
        }//from www.j  a  v  a 2 s .c  o  m
        return false;
    }

    public static int getCurrentMonth() {
        return currentDateTime(System.currentTimeMillis(), Calendar.MONTH);
    }

    public static int getMonth(long time) {
        return currentDateTime(time, Calendar.MONTH);
    }

    public static int getCurrentDay() {
        return currentDateTime(System.currentTimeMillis(), Calendar.DAY_OF_MONTH);
    }

    public static int getDay(long time) {
        return currentDateTime(time, Calendar.DAY_OF_MONTH);
    }

    private static int currentDateTime(long time, int type) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(time);
        return calendar.get(type);
    }
}

Related

  1. isToday(final Date date)
  2. isToday(final Date date)
  3. isToday(final Date date)
  4. isToday(int dateInt)
  5. isToDay(long millis)
  6. isToday(long timestamp)
  7. isToday(String depDateTime)
  8. isToday(String sdate)
  9. isToday(String sdate)