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   www .  ja  v a2  s.  c  o 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