Java SQL Date Create getLastSundayDate()

Here you can find the source of getLastSundayDate()

Description

Gets the last sunday date.

License

Open Source License

Return

the last sunday date

Declaration

public static Calendar getLastSundayDate() 

Method Source Code

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

import java.sql.Date;

import java.util.Calendar;

public class Main {
    /**/*from  w w  w  . j av a2  s  .  c  o m*/
     * Gets the last sunday date.
     * 
     * @return the last sunday date
     */
    public static Calendar getLastSundayDate() {
        Calendar cal = Calendar.getInstance();
        int daydiff = cal.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
        cal.add(Calendar.DATE, daydiff * -1);
        return cal;
    }

    /**
     * Gets the last sunday date.
     * 
     * @param d the d
     * 
     * @return the last sunday date
     */
    public static Calendar getLastSundayDate(Date d) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        int daydiff = cal.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
        cal.add(Calendar.DATE, daydiff * -1);
        return cal;
    }
}

Related

  1. getLastDay(Date dt)
  2. getLastDay(java.util.Date dt)
  3. getLastDayofMonth(Date date1)
  4. getLastDayOfMonth(java.sql.Date date)
  5. getLastDayOfPreviousMonth(Date date, boolean isFormatDate)
  6. getLongDate(String strDate)
  7. getSqlCurrentDate()
  8. getSqlCurrentDate()
  9. getSqlDate()