How to Subtract Minutes in Java


In this example we will show the method to subtract minutes in Java.

Source Code

package com.beginner.examples;

import java.util.Calendar;

public class SubtractMinutes {
  public static void main(String[] args){
    Calendar c = Calendar.getInstance();
    System.out.println(c.get(Calendar.MINUTE));
    //minutes subtract 1
    c.add(Calendar.MINUTE, -1);
    System.out.println(c.get(Calendar.MINUTE));
  }
}

Output:

17
16

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments