Java Day of Week getDateForCurrentWeekDay(int day)

Here you can find the source of getDateForCurrentWeekDay(int day)

Description

get Date For Current Week Day

License

Open Source License

Declaration

public static Date getDateForCurrentWeekDay(int day) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static Date getDateForCurrentWeekDay(int day) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day !
        cal.clear(Calendar.MINUTE);
        cal.clear(Calendar.SECOND);
        cal.clear(Calendar.MILLISECOND);
        cal.set(Calendar.DAY_OF_WEEK, day);
        return cal.getTime();
    }//w w w. ja va  2 s  .  c o  m

    public static Date getDateForCurrentWeekDay(Date date, int day) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DAY_OF_WEEK, day);
        return cal.getTime();
    }

    public static long getTime() {
        Date d = new Date();
        return (d.getTime());
    }

    public static long getTime(Date d) {
        return (d.getTime());
    }

    public static Date setTime(Date d, long time) {
        d.setTime(time);
        return (d);
    }
}

Related

  1. firstDayOfWeek()
  2. getAllDaysDateBetween(Date startDate, Date endDate, DayOfWeek dayOfWeek)
  3. getBounceDateofWeek(Date date)
  4. getDateByWeek(int week)
  5. getDateByYearAndWeekNum(int year, int weekNum)
  6. getDateOfWeek(int week)
  7. getDateOfWeek(int year, int weekOfYear, int i)
  8. getDateOfYearWeek(int yearNum, int weekNum, int dayOfWeek)
  9. getDateWeek(String date)