Here you can find the source of isSameDay(Calendar cal1, Calendar cal2)
Parameter | Description |
---|---|
cal1 | the first time |
cal2 | the second time |
public static boolean isSameDay(Calendar cal1, Calendar cal2)
//package com.java2s; /*//w w w . ja va 2s . c o m * Copyright SparseWare Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Calendar; public class Main { /** * Returns whether the two specified times are on the same day * @param cal1 the first time * @param cal2 the second time * @return true if the two specified times are on the same day; false otherwise */ public static boolean isSameDay(Calendar cal1, Calendar cal2) { if (cal1.get(Calendar.DAY_OF_YEAR) != cal2 .get(Calendar.DAY_OF_YEAR)) { return false; } if (cal1.get(Calendar.YEAR) != cal2.get(Calendar.YEAR)) { return false; } return true; } }