src/share/classes/java/util/Calendar.java

Print this page




1771 
1772     /**
1773      * Returns a field mask indicating which calendar field values
1774      * to be used to calculate the time value. The calendar fields are
1775      * returned as a bit mask, each bit of which corresponds to a field, i.e.,
1776      * the mask value of <code>field</code> is <code>(1 &lt;&lt;
1777      * field)</code>. For example, 0x26 represents the <code>YEAR</code>,
1778      * <code>MONTH</code>, and <code>DAY_OF_MONTH</code> fields (i.e., 0x26 is
1779      * equal to
1780      * <code>(1&lt;&lt;YEAR)|(1&lt;&lt;MONTH)|(1&lt;&lt;DAY_OF_MONTH))</code>.
1781      *
1782      * <p>This method supports the calendar fields resolution as described in
1783      * the class description. If the bit mask for a given field is on and its
1784      * field has not been set (i.e., <code>isSet(field)</code> is
1785      * <code>false</code>), then the default value of the field has to be
1786      * used, which case means that the field has been selected because the
1787      * selected combination involves the field.
1788      *
1789      * @return a bit mask of selected fields
1790      * @see #isExternallySet(int)
1791      * @see #setInternallySetState(int)
1792      */
1793     final int selectFields() {
1794         // This implementation has been taken from the GregorianCalendar class.
1795 
1796         // The YEAR field must always be used regardless of its SET
1797         // state because YEAR is a mandatory field to determine the date
1798         // and the default value (EPOCH_YEAR) may change through the
1799         // normalization process.
1800         int fieldMask = YEAR_MASK;
1801 
1802         if (stamp[ERA] != UNSET) {
1803             fieldMask |= ERA_MASK;
1804         }
1805         // Find the most recent group of fields specifying the day within
1806         // the year.  These may be any of the following combinations:
1807         //   MONTH + DAY_OF_MONTH
1808         //   MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
1809         //   MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
1810         //   DAY_OF_YEAR
1811         //   WEEK_OF_YEAR + DAY_OF_WEEK




1771 
1772     /**
1773      * Returns a field mask indicating which calendar field values
1774      * to be used to calculate the time value. The calendar fields are
1775      * returned as a bit mask, each bit of which corresponds to a field, i.e.,
1776      * the mask value of <code>field</code> is <code>(1 &lt;&lt;
1777      * field)</code>. For example, 0x26 represents the <code>YEAR</code>,
1778      * <code>MONTH</code>, and <code>DAY_OF_MONTH</code> fields (i.e., 0x26 is
1779      * equal to
1780      * <code>(1&lt;&lt;YEAR)|(1&lt;&lt;MONTH)|(1&lt;&lt;DAY_OF_MONTH))</code>.
1781      *
1782      * <p>This method supports the calendar fields resolution as described in
1783      * the class description. If the bit mask for a given field is on and its
1784      * field has not been set (i.e., <code>isSet(field)</code> is
1785      * <code>false</code>), then the default value of the field has to be
1786      * used, which case means that the field has been selected because the
1787      * selected combination involves the field.
1788      *
1789      * @return a bit mask of selected fields
1790      * @see #isExternallySet(int)

1791      */
1792     final int selectFields() {
1793         // This implementation has been taken from the GregorianCalendar class.
1794 
1795         // The YEAR field must always be used regardless of its SET
1796         // state because YEAR is a mandatory field to determine the date
1797         // and the default value (EPOCH_YEAR) may change through the
1798         // normalization process.
1799         int fieldMask = YEAR_MASK;
1800 
1801         if (stamp[ERA] != UNSET) {
1802             fieldMask |= ERA_MASK;
1803         }
1804         // Find the most recent group of fields specifying the day within
1805         // the year.  These may be any of the following combinations:
1806         //   MONTH + DAY_OF_MONTH
1807         //   MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
1808         //   MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
1809         //   DAY_OF_YEAR
1810         //   WEEK_OF_YEAR + DAY_OF_WEEK