Java - Write code to get Date by Week

Requirements

Write code to get Date by Week

Demo

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

public class Main {
  public static void main(String[] argv) {
    Date date = new Date();
    System.out.println(getDateIsWeek(date));
  }//from   w w  w.  j  a v a  2s.co  m

  public static int getDateIsWeek(Date date) {
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    int week = c.get(Calendar.DAY_OF_WEEK);
    return week;
  }
}

Related Exercise