Duration toMinutes() example

Description

Duration toMinutes() gets the number of minutes in this duration.

This returns the total number of minutes in the duration by dividing the number of seconds by 60.

Syntax

toMinutes has the following syntax.


public long toMinutes()

Example

The following example shows how to use toMinutes.


import java.time.Duration;
import java.time.LocalTime;
//from  w  w  w .j  a va  2s.  co  m
public class Main {
  public static void main(String[] args) {
    Duration duration = Duration.between(LocalTime.MIDNIGHT,LocalTime.NOON);
    System.out.println(duration.toMinutes());
    
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset