Java Milliseconds hasExpiredMillis(long now, long eventTime, long timeBuffer)

Here you can find the source of hasExpiredMillis(long now, long eventTime, long timeBuffer)

Description

Test whether a given event has timed out (in milliseconds).

License

Apache License

Parameter

Parameter Description
now Current instant.
eventTime Instant at which the event took place.
timeBuffer The amount of time for which the event is valid (in milliseconds).

Return

true if the event has expired, false otherwise

Declaration

public static boolean hasExpiredMillis(long now, long eventTime, long timeBuffer) 

Method Source Code

//package com.java2s;
/*/*from  www. j  a  v  a2s .  c o  m*/
 * Copyright 2010 Bruno de Carvalho
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Test whether a given event has timed out (in milliseconds).
     *
     * @param now        Current instant.
     * @param eventTime  Instant at which the event took place.
     * @param timeBuffer The amount of time for which the event is valid (in milliseconds).
     * @return <code>true</code> if the event has expired, <code>false</code> otherwise
     */
    public static boolean hasExpiredMillis(long now, long eventTime, long timeBuffer) {
        return (eventTime + timeBuffer) < now;
    }
}

Related

  1. getPeriodDurationInMillis(int period)
  2. GetTimeInMilliseconds(Date date)
  3. getTimeStringFromMilliseconds(long millis)
  4. getTimeZoneOffSetInMillisecond(String dateString)
  5. getUnitLengthMillis(String unit)
  6. hhmmssToMillis(String text)
  7. humanDateToMillisecondsWithoutException(String date)
  8. isSameSecondOfMillis(final long ms1, final long ms2)
  9. longToDate(long millis)