Here you can find the source of equalizeTime(final Calendar toEqualize, final Calendar source)
Parameter | Description |
---|---|
toEqualize | a Calendar, whose time will be equalized to the source's time of the day |
source | the time of the day of this Calendar is taken. |
public static Calendar equalizeTime(final Calendar toEqualize, final Calendar source)
//package com.java2s; /*// w w w.j a v a 2 s . c o m This file is part of Cyclos (www.cyclos.org). A project of the Social Trade Organisation (www.socialtrade.org). Cyclos 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 2 of the License, or (at your option) any later version. Cyclos 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 Cyclos; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.util.Calendar; public class Main { /** * sets the time of the day of the first argument, so that it is equal to the time of the day of the second argument. * @param toEqualize a Calendar, whose time will be equalized to the source's time of the day * @param source the time of the day of this Calendar is taken. * @return a new Calendar object, with the date equal to toEqualize, but the time of the date is equal to that of the source Calendar. */ public static Calendar equalizeTime(final Calendar toEqualize, final Calendar source) { if (source == null) { return null; } final int hourOfDay = source.get(Calendar.HOUR_OF_DAY); final int minute = source.get(Calendar.MINUTE); final int second = source.get(Calendar.SECOND); final int milliSecond = source.get(Calendar.MILLISECOND); final Calendar result = (Calendar) toEqualize.clone(); result.set(Calendar.HOUR_OF_DAY, hourOfDay); result.set(Calendar.MINUTE, minute); result.set(Calendar.SECOND, second); result.set(Calendar.MILLISECOND, milliSecond); return result; } }