Java Day of Week isSameWeekDates(Date date1, Date date2)

Here you can find the source of isSameWeekDates(Date date1, Date date2)

Description

is Same Week Dates

License

Apache License

Declaration

static boolean isSameWeekDates(Date date1, Date date2) 

Method Source Code

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

import java.util.Calendar;

import java.util.Date;

public class Main {

    static boolean isSameWeekDates(Date date1, Date date2) {
        long diff = getMonday(date1).getTime() - getMonday(date2).getTime();
        if (Math.abs(diff) < 1000 * 60 * 60 * 24) {
            return true;
        } else {//w w w  .j a v a 2  s  .c o m
            return false;
        }
    }

    public static Date getMonday(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        return c.getTime();
    }
}

Related

  1. getWeekth(String sDate)
  2. getYearOfWeek(Date date)
  3. incWeek(java.util.Date date, int amount, Locale locale)
  4. isMatchWeek(Date date, int week)
  5. isOnWeekend(Date date)
  6. isWeekday(Date startDate)
  7. isWeekDay(final Date date)
  8. isWeekEnd(Date date)
  9. isWeekend(Date date)