Android Year Get isInCurrentYear(long lTime)

Here you can find the source of isInCurrentYear(long lTime)

Description

is In Current Year

Declaration

public static boolean isInCurrentYear(long lTime) 

Method Source Code

//package com.java2s;
import java.util.Calendar;

public class Main {
    public static boolean isInCurrentYear(long lTime) {
        Calendar cal = Calendar.getInstance();
        Calendar calUnknown = Calendar.getInstance();
        cal.setTimeInMillis(System.currentTimeMillis());
        calUnknown.setTimeInMillis(lTime);
        int nDayOfYear = cal.get(Calendar.DAY_OF_YEAR);

        cal.add(Calendar.DAY_OF_YEAR, 0 - nDayOfYear);
        if (calUnknown.before(cal)) {
            return false;
        }//from  w ww .j  av a  2s  . co m
        cal.add(Calendar.DAY_OF_YEAR, 365);
        if (calUnknown.after(cal)) {
            return false;
        }
        return true;
    }
}

Related

  1. getIndexYear(Date origin, int index)
  2. getCurrentYear()
  3. getCurrentYear()
  4. getCurrentYear()
  5. getBeforeYear()
  6. getCurrentYear()
  7. getYear()
  8. getYearByMillis(long millis)