结果
上面的代码示例将产生以下结果。
today is 30 week of the year
today is a 5month of the year
today is a 4week of the month
以下是一年中的一周、一个月的另一个示例。
import java.util.Calendar;
public class GetWeekOfMonthAndYear {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
System.out.println("Current week of month is : " +cal.get(Calendar.WEEK_OF_MONTH));
System.out.println("Current week of year is : " +cal.get(Calendar.WEEK_OF_YEAR));
cal.add(Calendar.WEEK_OF_MONTH, 1);
System.out.println(
"date after one year : " + (cal.get(Calendar.MONTH) + 1)+ "-"+ cal.get(Calendar.DATE)+ "-"+ cal.get(Calendar.YEAR));
}
}
上面的代码示例将产生以下结果。
Current week of month is : 2
Current week of year is : 46
date after one year : 11-18-2016