toMinutesPart() is an instance method of the Duration class, which is used to obtain the number of minutes part in the Duration object. The number of minutes part is calculated by taking the modulus of the value that is returned by the toMinutes() method with the value 60. This is based on the traditional 60-minute definition of an hour. This method was introduced in Java version 9.
The toMinutesPart method is defined in the Duration class. The Duration class is defined in the java.time package. To import the Duration class, we check the following import statement:
import java.time.Duration;
public int toMinutesPart()
This method has no parameters.
This method returns the number of minutes part in the Duration object.
import java.time.Duration;public class Main {public static void main(String[] args) {Duration duration = Duration.ofSeconds(143234);long numOfMinutesPart = duration.toMinutesPart();System.out.printf("Number of mintues part in %s is %s", duration, numOfMinutesPart);}}
Duration class.Duration object, using the ofSeconds() method.Duration object, using the toMinutesPart() method.Duration object and the number of minutes part that we obtained in line 8.