Duration toDays() example

Description

Duration toDays() gets the number of days in this duration.

This returns the total number of days in the duration by dividing the number of seconds by 86400.

Syntax

toDays has the following syntax.


public long toDays()

Example

The following example shows how to use toDays.


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

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