Here you can find the source of areEqualTTL(final Integer ttlDuration1, final Integer ttlDuration2)
public static boolean areEqualTTL(final Integer ttlDuration1, final Integer ttlDuration2)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { public static boolean areEqualTTL(final Integer ttlDuration1, final Integer ttlDuration2) { return areEqualTTL(TimeUnit.SECONDS, ttlDuration1, TimeUnit.SECONDS, ttlDuration2); }// www . j a v a 2 s . c o m public static boolean areEqualTTL(final TimeUnit timeUnit1, final Integer ttlDuration1, final TimeUnit timeUnit2, final Integer ttlDuration2) { // If any one of them is not valid then we simply can't compare so return false if (!isValidTTL(timeUnit1, ttlDuration1) || !isValidTTL(timeUnit2, ttlDuration2)) { return false; } // Now both of them are valid TTL so compare seconds return timeUnit1.toSeconds(ttlDuration1) == timeUnit2 .toSeconds(ttlDuration2); } public static boolean isValidTTL(final Integer ttlDurationInSeconds) { if (ttlDurationInSeconds == null) { return false; } return isValidTTL(TimeUnit.SECONDS, ttlDurationInSeconds); } public static boolean isValidTTL(final TimeUnit timeUnit, final Integer ttlDuration) { if (timeUnit == null || ttlDuration == null) { return false; } if (timeUnit.toSeconds(ttlDuration) <= 0) { return false; } if (timeUnit.toSeconds(ttlDuration) > Integer.MAX_VALUE) { return false; } return true; } }