Here you can find the source of getSecondsPassedInHour()
public static int getSecondsPassedInHour()
//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; } }