Duration.from

Obtains an instance of {@code Duration} from a temporal amount. !(p) This obtains a duration based on the specified amount. A {@code TemporalAmount} represents an amount of time, which may be date-based or time-based, which this factory extracts to a duration. !(p) The conversion loops around the set of units from the amount and uses the {@linkplain TemporalUnit#getDuration() duration} of the unit to calculate the total {@code Duration}. Only a subset of units are accepted by this method. The unit must either have an {@linkplain TemporalUnit#isDurationEstimated() exact duration} or be {@link ChronoUnit#DAYS} which is treated as 24 hours. If any other units are found then an exception is thrown.

@param amount the temporal amount to convert, not null @return the equivalent duration, not null @throws DateTimeException if unable to convert to a {@code Duration} @throws ArithmeticException if numeric overflow occurs

class Duration
static
from

Meta