Java TimeUnit Usage isValidTTL(final Integer ttlDurationInSeconds)

Here you can find the source of isValidTTL(final Integer ttlDurationInSeconds)

Description

is Valid TTL

License

Open Source License

Declaration

public static boolean isValidTTL(final Integer ttlDurationInSeconds) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.TimeUnit;

public class Main {
    public static boolean isValidTTL(final Integer ttlDurationInSeconds) {
        if (ttlDurationInSeconds == null) {
            return false;
        }//  w w w . j  a  va 2s  .co m
        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;
    }
}

Related

  1. humanReadableDuration(Date from, Date to)
  2. humanReadableMillis(long millis)
  3. isCurrentDateBeforeAndWithinRangeOfDate( Date date, int rangeInDays)
  4. isTheSameDayCheckSummerTime(final Date day1, final Date day2, final boolean escapeYear)
  5. isTimedOut(long start, long timeout)
  6. julianDayToMillis(int julianDay)
  7. logDuration(org.slf4j.Logger log, String prefix, long startTimeNanos)
  8. logWatchStop(long start, String... params)
  9. mergeResults(List>> futures)