2664 * Returns a hash code for this calendar. 2665 * 2666 * @return a hash code value for this object. 2667 * @since 1.2 2668 */ 2669 @Override 2670 public int hashCode() { 2671 // 'otheritems' represents the hash code for the previous versions. 2672 int otheritems = (lenient ? 1 : 0) 2673 | (firstDayOfWeek << 1) 2674 | (minimalDaysInFirstWeek << 4) 2675 | (zone.hashCode() << 7); 2676 long t = getMillisOf(this); 2677 return (int) t ^ (int)(t >> 32) ^ otheritems; 2678 } 2679 2680 /** 2681 * Returns whether this <code>Calendar</code> represents a time 2682 * before the time represented by the specified 2683 * <code>Object</code>. This method is equivalent to: 2684 * <pre><blockquote> 2685 * compareTo(when) < 0 2686 * </blockquote></pre> 2687 * if and only if <code>when</code> is a <code>Calendar</code> 2688 * instance. Otherwise, the method returns <code>false</code>. 2689 * 2690 * @param when the <code>Object</code> to be compared 2691 * @return <code>true</code> if the time of this 2692 * <code>Calendar</code> is before the time represented by 2693 * <code>when</code>; <code>false</code> otherwise. 2694 * @see #compareTo(Calendar) 2695 */ 2696 public boolean before(Object when) { 2697 return when instanceof Calendar 2698 && compareTo((Calendar)when) < 0; 2699 } 2700 2701 /** 2702 * Returns whether this <code>Calendar</code> represents a time 2703 * after the time represented by the specified 2704 * <code>Object</code>. This method is equivalent to: 2705 * <pre><blockquote> 2706 * compareTo(when) > 0 2707 * </blockquote></pre> 2708 * if and only if <code>when</code> is a <code>Calendar</code> 2709 * instance. Otherwise, the method returns <code>false</code>. 2710 * 2711 * @param when the <code>Object</code> to be compared 2712 * @return <code>true</code> if the time of this <code>Calendar</code> is 2713 * after the time represented by <code>when</code>; <code>false</code> 2714 * otherwise. 2715 * @see #compareTo(Calendar) 2716 */ 2717 public boolean after(Object when) { 2718 return when instanceof Calendar 2719 && compareTo((Calendar)when) > 0; 2720 } 2721 2722 /** 2723 * Compares the time values (millisecond offsets from the <a 2724 * href="#Epoch">Epoch</a>) represented by two 2725 * <code>Calendar</code> objects. 2726 * 2727 * @param anotherCalendar the <code>Calendar</code> to be compared. | 2664 * Returns a hash code for this calendar. 2665 * 2666 * @return a hash code value for this object. 2667 * @since 1.2 2668 */ 2669 @Override 2670 public int hashCode() { 2671 // 'otheritems' represents the hash code for the previous versions. 2672 int otheritems = (lenient ? 1 : 0) 2673 | (firstDayOfWeek << 1) 2674 | (minimalDaysInFirstWeek << 4) 2675 | (zone.hashCode() << 7); 2676 long t = getMillisOf(this); 2677 return (int) t ^ (int)(t >> 32) ^ otheritems; 2678 } 2679 2680 /** 2681 * Returns whether this <code>Calendar</code> represents a time 2682 * before the time represented by the specified 2683 * <code>Object</code>. This method is equivalent to: 2684 * <pre>{@code 2685 * compareTo(when) < 0 2686 * }</pre> 2687 * if and only if <code>when</code> is a <code>Calendar</code> 2688 * instance. Otherwise, the method returns <code>false</code>. 2689 * 2690 * @param when the <code>Object</code> to be compared 2691 * @return <code>true</code> if the time of this 2692 * <code>Calendar</code> is before the time represented by 2693 * <code>when</code>; <code>false</code> otherwise. 2694 * @see #compareTo(Calendar) 2695 */ 2696 public boolean before(Object when) { 2697 return when instanceof Calendar 2698 && compareTo((Calendar)when) < 0; 2699 } 2700 2701 /** 2702 * Returns whether this <code>Calendar</code> represents a time 2703 * after the time represented by the specified 2704 * <code>Object</code>. This method is equivalent to: 2705 * <pre>{@code 2706 * compareTo(when) > 0 2707 * }</pre> 2708 * if and only if <code>when</code> is a <code>Calendar</code> 2709 * instance. Otherwise, the method returns <code>false</code>. 2710 * 2711 * @param when the <code>Object</code> to be compared 2712 * @return <code>true</code> if the time of this <code>Calendar</code> is 2713 * after the time represented by <code>when</code>; <code>false</code> 2714 * otherwise. 2715 * @see #compareTo(Calendar) 2716 */ 2717 public boolean after(Object when) { 2718 return when instanceof Calendar 2719 && compareTo((Calendar)when) > 0; 2720 } 2721 2722 /** 2723 * Compares the time values (millisecond offsets from the <a 2724 * href="#Epoch">Epoch</a>) represented by two 2725 * <code>Calendar</code> objects. 2726 * 2727 * @param anotherCalendar the <code>Calendar</code> to be compared. |