Print Week Example Java Program


Syntax

Variable_name=Calendar.WEEK_OF_MONTH
Variable_name=Calendar.WEEK_OF_YEAR

Print Week Example Program

import java.util.Calendar;
 
public class PrintWeek {
	public static void main(String[] args) {
		Calendar c = Calendar.getInstance();
		System.out.println("Current week of month is : " +c.get(Calendar.WEEK_OF_MONTH));
		System.out.println("Current week of year is : " +c.get(Calendar.WEEK_OF_YEAR));
	}
}

Sample Output

Output is:
Current week of month is : 2
Current week of year is : 19