Java Hour getSecondsPassedInHour()

Here you can find the source of getSecondsPassedInHour()

Description

get Seconds Passed In Hour

License

Open Source License

Declaration

public static int getSecondsPassedInHour() 

Method Source Code

//package com.java2s;
/*/*from   www. java2 s  .  c o m*/
 *  This program 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
 *  (at your option) any later version.
 *
 *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  copyright (C) 2012 nambi sankaran.
 */

import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {
    public static final long YEAR = 365L * 24L * 60L * 60L * 1000L;
    public static final long MONTH = 30L * 24L * 60L * 60L * 1000L;

    public static int getSecondsPassedInHour() {
        Calendar cur = GregorianCalendar.getInstance();

        Calendar calendar = GregorianCalendar.getInstance();
        calendar.set(cur.get(Calendar.YEAR), cur.get(Calendar.MONTH), cur.get(Calendar.DATE),
                cur.get(Calendar.HOUR_OF_DAY), 0);

        long currenttime = cur.getTime().getTime();
        long hourtime = calendar.getTime().getTime();

        long millis = currenttime - hourtime;
        int result = (int) (millis / 1000);
        return result;
    }
}

Related

  1. getLasthour()
  2. getMinOfHour(long l1)
  3. getPreHour()
  4. getPreHourText(String pattern)
  5. getPrevHour(Date date)
  6. getTaskTrigger(int taskTriggerHour, boolean tomorrow)
  7. getTicksTill(int hour)
  8. getTicksTillHour()
  9. hour()