Here you can find the source of getTTLSeconds(Duration duration)
public static final int getTTLSeconds(Duration duration)
//package com.java2s; //License from project: Apache License import com.google.common.base.Preconditions; import java.time.Duration; import java.time.temporal.TemporalUnit; public class Main { public static final int getTTLSeconds(Duration duration) { Preconditions.checkArgument(duration != null && !duration.isZero(), "Must provide non-zero TTL"); long ttlSeconds = Math.max(1, duration.getSeconds()); assert ttlSeconds > 0; Preconditions.checkArgument(ttlSeconds <= Integer.MAX_VALUE, "tll value is too large [%s] - value overflow", duration);/*from w w w. j a v a 2 s. c o m*/ return (int) ttlSeconds; } public static final int getTTLSeconds(long time, TemporalUnit unit) { return getTTLSeconds(Duration.of(time, unit)); } }