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