jdk/src/share/classes/java/util/Calendar.java
changeset 6491 cd1bcc5057f4
parent 6489 9e7015635425
child 6501 684810d882b3
equal deleted inserted replaced
6489:9e7015635425 6491:cd1bcc5057f4
     1 /*
     1 /*
     2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   117  * <code>DAY_OF_MONTH</code> values between 1 and the length of the month. A
   117  * <code>DAY_OF_MONTH</code> values between 1 and the length of the month. A
   118  * non-lenient <code>GregorianCalendar</code> throws an exception upon
   118  * non-lenient <code>GregorianCalendar</code> throws an exception upon
   119  * calculating its time or calendar field values if any out-of-range field
   119  * calculating its time or calendar field values if any out-of-range field
   120  * value has been set.
   120  * value has been set.
   121  *
   121  *
   122  * <h4>First Week</h4>
   122  * <h4><a name="first_week">First Week</a></h4>
   123  *
   123  *
   124  * <code>Calendar</code> defines a locale-specific seven day week using two
   124  * <code>Calendar</code> defines a locale-specific seven day week using two
   125  * parameters: the first day of the week and the minimal days in first week
   125  * parameters: the first day of the week and the minimal days in first week
   126  * (from 1 to 7).  These numbers are taken from the locale resource data when a
   126  * (from 1 to 7).  These numbers are taken from the locale resource data when a
   127  * <code>Calendar</code> is constructed.  They may also be specified explicitly
   127  * <code>Calendar</code> is constructed.  They may also be specified explicitly
  2194     {
  2194     {
  2195         return minimalDaysInFirstWeek;
  2195         return minimalDaysInFirstWeek;
  2196     }
  2196     }
  2197 
  2197 
  2198     /**
  2198     /**
       
  2199      * Returns whether this {@code Calendar} supports week dates.
       
  2200      *
       
  2201      * <p>The default implementation of this method returns {@code false}.
       
  2202      *
       
  2203      * @return {@code true} if this {@code Calendar} supports week dates;
       
  2204      *         {@code false} otherwise.
       
  2205      * @see #getWeekYear()
       
  2206      * @see #setWeekDate(int,int,int)
       
  2207      * @see #getWeeksInWeekYear()
       
  2208      * @since 1.7
       
  2209      */
       
  2210     public boolean isWeekDateSupported() {
       
  2211         return false;
       
  2212     }
       
  2213 
       
  2214     /**
       
  2215      * Returns the week year represented by this {@code Calendar}. The
       
  2216      * week year is in sync with the week cycle. The {@linkplain
       
  2217      * #getFirstDayOfWeek() first day of the first week} is the first
       
  2218      * day of the week year.
       
  2219      *
       
  2220      * <p>The default implementation of this method throws an
       
  2221      * {@link UnsupportedOperationException}.
       
  2222      *
       
  2223      * @return the week year of this {@code Calendar}
       
  2224      * @exception UnsupportedOperationException
       
  2225      *            if any week year numbering isn't supported
       
  2226      *            in this {@code Calendar}.
       
  2227      * @see #isWeekDateSupported()
       
  2228      * @see #getFirstDayOfWeek()
       
  2229      * @see #getMinimalDaysInFirstWeek()
       
  2230      * @since 1.7
       
  2231      */
       
  2232     public int getWeekYear() {
       
  2233         throw new UnsupportedOperationException();
       
  2234     }
       
  2235 
       
  2236     /**
       
  2237      * Sets the date of this {@code Calendar} with the the given date
       
  2238      * specifiers - week year, week of year, and day of week.
       
  2239      *
       
  2240      * <p>Unlike the {@code set} method, all of the calendar fields
       
  2241      * and {@code time} values are calculated upon return.
       
  2242      *
       
  2243      * <p>If {@code weekOfYear} is out of the valid week-of-year range
       
  2244      * in {@code weekYear}, the {@code weekYear} and {@code
       
  2245      * weekOfYear} values are adjusted in lenient mode, or an {@code
       
  2246      * IllegalArgumentException} is thrown in non-lenient mode.
       
  2247      *
       
  2248      * <p>The default implementation of this method throws an
       
  2249      * {@code UnsupportedOperationException}.
       
  2250      *
       
  2251      * @param weekYear   the week year
       
  2252      * @param weekOfYear the week number based on {@code weekYear}
       
  2253      * @param dayOfWeek  the day of week value: one of the constants
       
  2254      *                   for the {@link #DAY_OF_WEEK} field: {@link
       
  2255      *                   #SUNDAY}, ..., {@link #SATURDAY}.
       
  2256      * @exception IllegalArgumentException
       
  2257      *            if any of the given date specifiers is invalid
       
  2258      *            or any of the calendar fields are inconsistent
       
  2259      *            with the given date specifiers in non-lenient mode
       
  2260      * @exception UnsupportedOperationException
       
  2261      *            if any week year numbering isn't supported in this
       
  2262      *            {@code Calendar}.
       
  2263      * @see #isWeekDateSupported()
       
  2264      * @see #getFirstDayOfWeek()
       
  2265      * @see #getMinimalDaysInFirstWeek()
       
  2266      * @since 1.7
       
  2267      */
       
  2268     public void setWeekDate(int weekYear, int weekOfYear, int dayOfWeek) {
       
  2269         throw new UnsupportedOperationException();
       
  2270     }
       
  2271 
       
  2272     /**
       
  2273      * Returns the number of weeks in the week year represented by this
       
  2274      * {@code Calendar}.
       
  2275      *
       
  2276      * <p>The default implementation of this method throws an
       
  2277      * {@code UnsupportedOperationException}.
       
  2278      *
       
  2279      * @return the number of weeks in the week year.
       
  2280      * @exception UnsupportedOperationException
       
  2281      *            if any week year numbering isn't supported in this
       
  2282      *            {@code Calendar}.
       
  2283      * @see #WEEK_OF_YEAR
       
  2284      * @see #isWeekDateSupported()
       
  2285      * @see #getWeekYear()
       
  2286      * @see #getActualMaximum(int)
       
  2287      * @since 1.7
       
  2288      */
       
  2289     public int getWeeksInWeekYear() {
       
  2290         throw new UnsupportedOperationException();
       
  2291     }
       
  2292 
       
  2293     /**
  2199      * Returns the minimum value for the given calendar field of this
  2294      * Returns the minimum value for the given calendar field of this
  2200      * <code>Calendar</code> instance. The minimum value is defined as
  2295      * <code>Calendar</code> instance. The minimum value is defined as
  2201      * the smallest value returned by the {@link #get(int) get} method
  2296      * the smallest value returned by the {@link #get(int) get} method
  2202      * for any possible time value.  The minimum value depends on
  2297      * for any possible time value.  The minimum value depends on
  2203      * calendar system specific parameters of the instance.
  2298      * calendar system specific parameters of the instance.