Java Hour getTicksTillHour()

Here you can find the source of getTicksTillHour()

Description

Gets the ticks till the start of the next hour

License

Open Source License

Return

the number of ticks till the next hour

Declaration

public static long getTicksTillHour() 

Method Source Code


//package com.java2s;
/*//  w  w w.j  a  va  2s .  c o  m
 * Copyright (c) 2014 Wyatt Childers.
 *
 * This file is part of Aurora.
 *
 * Aurora is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Aurora 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with Aurora.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Calendar;

public class Main {
    private static Calendar calendar = Calendar.getInstance();

    /**
     * Gets the ticks till the start of the next hour
     *
     * @return the number of ticks till the next hour
     */
    public static long getTicksTillHour() {

        Calendar localCalendar = Calendar.getInstance();
        long returnValue;

        localCalendar.set(Calendar.MINUTE, 0);
        localCalendar.add(Calendar.HOUR_OF_DAY, 1);

        returnValue = localCalendar.getTimeInMillis() - calendar.getTimeInMillis();
        returnValue = (returnValue / 1000) * 20; // To Ticks

        return returnValue;
    }
}

Related

  1. getPreHourText(String pattern)
  2. getPrevHour(Date date)
  3. getSecondsPassedInHour()
  4. getTaskTrigger(int taskTriggerHour, boolean tomorrow)
  5. getTicksTill(int hour)
  6. hour()
  7. hour()
  8. hourAgo()
  9. hourCompletion(boolean hourPresent, int hour, boolean minutePresent, int minute, boolean secondPresent, int second, boolean milliPresent, int milli, String choice)