Android Date Interval Get getFirstInterval(Context context, long lastupdate, long updateinterval)

Here you can find the source of getFirstInterval(Context context, long lastupdate, long updateinterval)

Description

Gets the first interval for setting an alarm.

Parameter

Parameter Description
context a parameter

Declaration

private static long getFirstInterval(Context context, long lastupdate,
        long updateinterval) 

Method Source Code

//package com.java2s;
import android.content.Context;

import android.util.Log;

public class Main {
    public static final String TAG = "AlarmUtils";

    /**//from   ww w  . j av a  2  s .c o m
     * Gets the first interval for setting an alarm.
     * 
     * It is calculated using the last time of a successful update.
     * 
     * @param context
     * @return
     */
    private static long getFirstInterval(Context context, long lastupdate,
            long updateinterval) {
        long now = System.currentTimeMillis();

        long firstinterval = lastupdate - now + updateinterval;

        if (firstinterval < 0) {
            Log.d(TAG, "Limit first interval from " + firstinterval
                    + " to " + 0);
            firstinterval = 0;
        } else if (firstinterval > updateinterval) {
            Log.d(TAG, "Limit first interval from " + firstinterval
                    + " to " + updateinterval);
            firstinterval = updateinterval;
        }

        return firstinterval;
    }
}

Related

  1. getDateOffset()
  2. interval(Date date)
  3. checkIsIntervalDay(String startTime, String endTime)
  4. totalDays(Object o)
  5. calculatorDaysAgo(String date, Locale locale, String format)
  6. timeDifference(Date date)
  7. getTimeRangeStr(Date startDate, Date endDate)
  8. formatDuration(int duration)
  9. calcTimeBetween(Date start, Date end)