Here you can find the source of sameHour(Calendar one, Calendar two)
Parameter | Description |
---|---|
one | The one calendar. |
two | The other calendar. |
public static boolean sameHour(Calendar one, Calendar two)
//package com.java2s; //License from project: Apache License import java.util.Calendar; public class Main { /**/*from ww w.jav a 2 s . c o m*/ * Returns <tt>true</tt> if the two given calendars are dated on the same year, month, day and * hour. * @param one The one calendar. * @param two The other calendar. * @return True if the two given calendars are dated on the same year, month, day and hour. */ public static boolean sameHour(Calendar one, Calendar two) { return one.get(Calendar.HOUR_OF_DAY) == two.get(Calendar.HOUR_OF_DAY) && sameDay(one, two); } /** * Returns <tt>true</tt> if the two given calendars are dated on the same year, month and day. * @param one The one calendar. * @param two The other calendar. * @return True if the two given calendars are dated on the same year, month and day. */ public static boolean sameDay(Calendar one, Calendar two) { return one.get(Calendar.DATE) == two.get(Calendar.DATE) && sameMonth(one, two); } /** * Returns <tt>true</tt> if the two given calendars are dated on the same year and month. * @param one The one calendar. * @param two The other calendar. * @return True if the two given calendars are dated on the same year and month. */ public static boolean sameMonth(Calendar one, Calendar two) { return one.get(Calendar.MONTH) == two.get(Calendar.MONTH) && sameYear(one, two); } /** * Returns <tt>true</tt> if the two given calendars are dated on the same year. * @param one The one calendar. * @param two The other calendar. * @return True if the two given calendars are dated on the same year. */ public static boolean sameYear(Calendar one, Calendar two) { return one.get(Calendar.YEAR) == two.get(Calendar.YEAR); } }