Android Second to Time timeRemaining(double seconds)

Here you can find the source of timeRemaining(double seconds)

Description

Controls a while-loop for a specific number of seconds.

License

Open Source License

Parameter

Parameter Description
seconds number of seconds to loop

Return

true iff the specified number of seconds has not elapsed

Declaration

public static boolean timeRemaining(double seconds) 

Method Source Code

//package com.java2s;
/*/*from  ww w.  j a  v a  2s  . c  o m*/
 * Myro/Java license - GPL
 * 
 * Myro/Java is a Java implementation of the Myro API, defined by the Institute for Robots in
 * Education (IPRE).  See http://wiki.roboteducation.org for more information.
 * 
 * Copyright 2010-2011 Douglas Harms dharms@depauw.edu
 * 
 * This file is part of Myro/Java.
 * 
 * Myro/Java is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 * 
 * Myro/Java is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Myro/Java.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    private static boolean _newCountDown;
    private static long _startTime;

    /**
     * Controls a while-loop for a specific number of seconds.
     * 
     * @param seconds number of seconds to loop
     * @return true iff the specified number of seconds has not elapsed
     */
    public static boolean timeRemaining(double seconds) {
        if (_newCountDown) {
            _startTime = System.currentTimeMillis();
            _newCountDown = false;
        }

        if (System.currentTimeMillis() <= _startTime + seconds * 1000)
            return true;
        else {
            _newCountDown = true;
            return false;
        }
    }
}

Related

  1. secsToText(long time)
  2. calculateDhms(int seconds)
  3. secondsToString(int seconds)
  4. intSecondsToStringMinSec(int input)
  5. getTimeRemaining(long durationInMilliseconds)
  6. getDfferenceInMinute(long miliseconds)
  7. getTimeForm(long milliseconds)
  8. milliSecondsToTimer(long milliseconds)
  9. getTime(int minutes, int seconds)