Java examples for java.util:Hour
snap End Of Hour
/******************************************************************************* * Copyright (c) 2004, 2009 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w w w . j av a 2s . c o m*/ * Tasktop Technologies - initial API and implementation *******************************************************************************/ //package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { Calendar cal = Calendar.getInstance(); System.out.println(snapEndOfHour(cal)); } public static Calendar snapEndOfHour(Calendar cal) { cal.set(Calendar.MINUTE, cal.getActualMaximum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getActualMaximum(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal.getActualMaximum(Calendar.MILLISECOND)); cal.getTime(); return cal; } }