In this example we will show the method to subtract weeks in Java.
Source Code
package com.beginner.examples;
import java.util.Calendar;
public class SubtractWeeks {
public static void main(String[] args){
Calendar c = Calendar.getInstance();
System.out.println(c.get(Calendar.WEEK_OF_YEAR));
//weeks subtract 1
c.add(Calendar.WEEK_OF_YEAR, -1);
System.out.println(c.get(Calendar.WEEK_OF_YEAR));
}
}
Output:
26
25
References
Imported packages in Java documentation: