Java Day of Week startOfWeek(Date date)

Here you can find the source of startOfWeek(Date date)

Description

start Of Week

License

Open Source License

Declaration

public static Date startOfWeek(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date startOfWeek(Date date) {
        if (date == null) {
            return date;
        }// w  w  w .ja v  a  2  s  .  c  o m
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        System.out.println("Today:  " + c.getTime());
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        Date start = c.getTime();
        return newDate(start.getYear(), start.getMonth(), start.getDay(), 0, 0, 0);
    }

    /**
     *
     * @param year
     * @param month
     * @param day
     * @param hour
     * @param minute
     * @param sencond
     * @return
     */
    public static Date newDate(int year, int month, int day, int hour, int minute, int sencond) {
        if (month >= 1) {
            month = month - 1;
        }
        return new Date(year + 1900, month, day, hour, minute, sencond);
    }
}

Related

  1. nextDayOfWeek(Date fromDate, int dow)
  2. nextWeek(Date date)
  3. nextWeek(final Date date)
  4. previousWeek(long date)
  5. previousWeek(long date)
  6. toStartWeek(Date date)
  7. toWeekDayUS(Date date, int expect)
  8. truncDateToIsoWeek(Date d)
  9. weekCount(Date start, Date end)