OffsetTime minusMinutes() method in Java with examples

The minusMinutes() method of OffsetTime class in Java returns a copy of this OffsetTime with the specified Minutes in the parameter getting subtracted.

Syntax :

public OffsetTime minusMinutes(long Minutes)

Parameter: This method accepts a single parameter Minutes which the Minutes to be subtracted. It may be negative.



Return Value: It returns a OffsetTime based on this time with the Minutes subtracted and it is not null.

Below programs illustrate the minusMinutes() method:

Program 1 :

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to demonstrate the minusMinutes() method
  
import java.time.OffsetTime;
  
public class GFG {
    public static void main(String[] args)
    {
        // Parses the time
        OffsetTime time = OffsetTime.parse("11:10:10+05:05");
  
        // Specified Minutes subtracted
        System.out.println("After subtraction, time is: "
                                     + time.minusMinutes(5));
    }
}

chevron_right


Output:

After subtraction, time is: 11:05:10+05:05

Program 2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to demonstrate the minusMinutes() method
  
import java.time.OffsetTime;
  
public class GFG {
    public static void main(String[] args)
    {
        // Parses the time
        OffsetTime time = OffsetTime.parse("11:10:10+05:05");
  
        // Specified Minutes subtracted
        System.out.println("After subtraction, time is: " 
                                     + time.minusMinutes(-5));
    }
}

chevron_right


Output:

After subtraction, time is: 11:15:10+05:05

Reference: https://docs.oracle.com/javase/8/docs/api/java/time/OffsetTime.html#minusMinutes-long-




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.