Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; import android.util.Log; public class Main { public static boolean isPastWeek(Date date) { Date currentDate = new Date(); Date firstTimeOfWeek = firstTimeOfWeek(currentDate); float currentSecond = secondFromMilisecond(firstTimeOfWeek.getTime()); float actuallySecond = secondFromMilisecond(date.getTime()); float delta = actuallySecond - currentSecond; Log.v("Time currentDate", "" + currentDate); Log.v("Time currentSecond", "" + firstTimeOfWeek); Log.v("Time actuallySecond", "" + date); Log.v("Time delta", "" + delta); if (delta >= 0 && delta < 60 * 60 * 24 * 7) { return true; } return false; } public static Date firstTimeOfWeek(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(date.getTime()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); Date dateBegin = new Date(); dateBegin.setTime(calendar.getTimeInMillis()); return dateBegin; } public static float secondFromMilisecond(float milisecond) { return milisecond / 1000; } }