Android Long to Week Convert isInLastWeek(long lTime)

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

Description

is In Last Week

Declaration

public static boolean isInLastWeek(long lTime) 

Method Source Code

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

public class Main {
    public static boolean isInLastWeek(long lTime) {
        Calendar calToday = Calendar.getInstance();
        Calendar calUnknown = Calendar.getInstance();
        calToday.setTimeInMillis(System.currentTimeMillis());
        calUnknown.setTimeInMillis(lTime);
        int nDayOfWeek = calToday.get(Calendar.DAY_OF_WEEK);
        if (nDayOfWeek == Calendar.SUNDAY) {
            nDayOfWeek = Calendar.SATURDAY + 1;
        }/*from   w  ww  .  j a v  a 2 s  . c  om*/
        nDayOfWeek -= 1;
        calToday.add(Calendar.DAY_OF_YEAR, -(nDayOfWeek - 1));
        if (calUnknown.after(calToday)) {
            return false;
        }
        calToday.add(Calendar.DAY_OF_YEAR, -7);
        if (calUnknown.before(calToday)) {
            return false;
        }
        return true;
    }
}

Related

  1. isInNextWeek(long lTime)
  2. isInCurrentWeek(long lTime)
  3. isBeyondNextWeek(long lTime)
  4. addWeek(long dateTimeMillis)
  5. addWeek(long dateTimeMillis)