我想找到给定日期之间的一周范围

时间:2016-02-17 08:01:06

标签: java android

[用户必须输入日期,然后我必须显示给定日期之间的星期范围,对于此实例,范围应为

开课日期:2016年1月10日星期日,截止日期:2016年1月16日星期六] 1

public static void main(String[] args) {

    Calendar c = Calendar.getInstance();
    //get the day from the user

    //c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); //I want to set the date here

    //The range of the given day   
    System.out.print("Start Date : " + c.getTime() + ", ");
    c.add(Calendar.DAY_OF_WEEK, 6);
    System.out.println("End Date : " + c.getTime());
    c.add(Calendar.DAY_OF_WEEK, 1);

}

0 个答案:

没有答案