< prev index next >

src/java.base/share/classes/java/util/GregorianCalendar.java

Print this page




 142  * ending on the day before <code>getFirstDayOfWeek()</code>.  Unlike
 143  * week 1 of a year, week 1 of a month may be shorter than 7 days, need
 144  * not start on <code>getFirstDayOfWeek()</code>, and will not include days of
 145  * the previous month.  Days of a month before week 1 have a
 146  * <code>WEEK_OF_MONTH</code> of 0.
 147  *
 148  * <p>For example, if <code>getFirstDayOfWeek()</code> is <code>SUNDAY</code>
 149  * and <code>getMinimalDaysInFirstWeek()</code> is 4, then the first week of
 150  * January 1998 is Sunday, January 4 through Saturday, January 10.  These days
 151  * have a <code>WEEK_OF_MONTH</code> of 1.  Thursday, January 1 through
 152  * Saturday, January 3 have a <code>WEEK_OF_MONTH</code> of 0.  If
 153  * <code>getMinimalDaysInFirstWeek()</code> is changed to 3, then January 1
 154  * through January 3 have a <code>WEEK_OF_MONTH</code> of 1.
 155  *
 156  * <h4>Default Fields Values</h4>
 157  *
 158  * <p>The <code>clear</code> method sets calendar field(s)
 159  * undefined. <code>GregorianCalendar</code> uses the following
 160  * default value for each calendar field if its value is undefined.
 161  *
 162  * <table cellpadding="0" cellspacing="3" border="0"
 163  *        summary="GregorianCalendar default field values"
 164  *        style="text-align: left; width: 66%;">
 165  *   <tbody>
 166  *     <tr>
 167  *       <th style="vertical-align: top; background-color: rgb(204, 204, 255);
 168  *           text-align: center;">Field<br>
 169  *       </th>
 170  *       <th style="vertical-align: top; background-color: rgb(204, 204, 255);
 171  *           text-align: center;">Default Value<br>
 172  *       </th>
 173  *     </tr>


 174  *     <tr>
 175  *       <td style="vertical-align: middle;">
 176  *              <code>ERA<br></code>
 177  *       </td>
 178  *       <td style="vertical-align: middle;">
 179  *              <code>AD<br></code>
 180  *       </td>
 181  *     </tr>
 182  *     <tr>
 183  *       <td style="vertical-align: middle; background-color: rgb(238, 238, 255);">
 184  *              <code>YEAR<br></code>
 185  *       </td>
 186  *       <td style="vertical-align: middle; background-color: rgb(238, 238, 255);">
 187  *              <code>1970<br></code>
 188  *       </td>
 189  *     </tr>
 190  *     <tr>
 191  *       <td style="vertical-align: middle;">
 192  *              <code>MONTH<br></code>
 193  *       </td>
 194  *       <td style="vertical-align: middle;">
 195  *              <code>JANUARY<br></code>
 196  *       </td>
 197  *     </tr>
 198  *     <tr>
 199  *       <td style="vertical-align: top; background-color: rgb(238, 238, 255);">
 200  *              <code>DAY_OF_MONTH<br></code>
 201  *       </td>
 202  *       <td style="vertical-align: top; background-color: rgb(238, 238, 255);">
 203  *              <code>1<br></code>
 204  *       </td>
 205  *     </tr>
 206  *     <tr>
 207  *       <td style="vertical-align: middle;">
 208  *              <code>DAY_OF_WEEK<br></code>
 209  *       </td>
 210  *       <td style="vertical-align: middle;">
 211  *              <code>the first day of week<br></code>
 212  *       </td>
 213  *     </tr>
 214  *     <tr>
 215  *       <td style="vertical-align: top; background-color: rgb(238, 238, 255);">
 216  *              <code>WEEK_OF_MONTH<br></code>
 217  *       </td>
 218  *       <td style="vertical-align: top; background-color: rgb(238, 238, 255);">
 219  *              <code>0<br></code>
 220  *       </td>
 221  *     </tr>
 222  *     <tr>
 223  *       <td style="vertical-align: top;">
 224  *              <code>DAY_OF_WEEK_IN_MONTH<br></code>
 225  *       </td>
 226  *       <td style="vertical-align: top;">
 227  *              <code>1<br></code>
 228  *       </td>
 229  *     </tr>
 230  *     <tr>
 231  *       <td style="vertical-align: middle; background-color: rgb(238, 238, 255);">
 232  *              <code>AM_PM<br></code>
 233  *       </td>
 234  *       <td style="vertical-align: middle; background-color: rgb(238, 238, 255);">
 235  *              <code>AM<br></code>
 236  *       </td>
 237  *     </tr>
 238  *     <tr>
 239  *       <td style="vertical-align: middle;">
 240  *              <code>HOUR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND<br></code>
 241  *       </td>
 242  *       <td style="vertical-align: middle;">
 243  *              <code>0<br></code>
 244  *       </td>
 245  *     </tr>
 246  *   </tbody>
 247  * </table>
 248  * <br>Default values are not applicable for the fields not listed above.
 249  *
 250  * <p>
 251  * <strong>Example:</strong>
 252  * <blockquote>
 253  * <pre>
 254  * // get the supported ids for GMT-08:00 (Pacific Standard Time)
 255  * String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
 256  * // if no ids were returned, something is wrong. get out.
 257  * if (ids.length == 0)
 258  *     System.exit(0);
 259  *
 260  *  // begin output
 261  * System.out.println("Current Time");
 262  *
 263  * // create a Pacific Standard Time time zone




 142  * ending on the day before <code>getFirstDayOfWeek()</code>.  Unlike
 143  * week 1 of a year, week 1 of a month may be shorter than 7 days, need
 144  * not start on <code>getFirstDayOfWeek()</code>, and will not include days of
 145  * the previous month.  Days of a month before week 1 have a
 146  * <code>WEEK_OF_MONTH</code> of 0.
 147  *
 148  * <p>For example, if <code>getFirstDayOfWeek()</code> is <code>SUNDAY</code>
 149  * and <code>getMinimalDaysInFirstWeek()</code> is 4, then the first week of
 150  * January 1998 is Sunday, January 4 through Saturday, January 10.  These days
 151  * have a <code>WEEK_OF_MONTH</code> of 1.  Thursday, January 1 through
 152  * Saturday, January 3 have a <code>WEEK_OF_MONTH</code> of 0.  If
 153  * <code>getMinimalDaysInFirstWeek()</code> is changed to 3, then January 1
 154  * through January 3 have a <code>WEEK_OF_MONTH</code> of 1.
 155  *
 156  * <h4>Default Fields Values</h4>
 157  *
 158  * <p>The <code>clear</code> method sets calendar field(s)
 159  * undefined. <code>GregorianCalendar</code> uses the following
 160  * default value for each calendar field if its value is undefined.
 161  *
 162  * <table class="striped" style="text-align: left; width: 66%;">
 163  * <caption style="display:none">GregorianCalendar default field values</caption>
 164  *   <thead>

 165  *     <tr>
 166  *       <th>
 167  *          Field
 168  *       </th>
 169  *       <th>
 170             Default Value
 171  *       </th>
 172  *     </tr>
 173  *   </thead>
 174  *   <tbody>
 175  *     <tr>
 176  *       <td>
 177  *              <code>ERA</code>
 178  *       </td>
 179  *       <td>
 180  *              <code>AD</code>
 181  *       </td>
 182  *     </tr>
 183  *     <tr>
 184  *       <td>
 185  *              <code>YEAR</code>
 186  *       </td>
 187  *       <td>
 188  *              <code>1970</code>
 189  *       </td>
 190  *     </tr>
 191  *     <tr>
 192  *       <td>
 193  *              <code>MONTH</code>
 194  *       </td>
 195  *       <td>
 196  *              <code>JANUARY</code>
 197  *       </td>
 198  *     </tr>
 199  *     <tr>
 200  *       <td>
 201  *              <code>DAY_OF_MONTH</code>
 202  *       </td>
 203  *       <td>
 204  *              <code>1</code>
 205  *       </td>
 206  *     </tr>
 207  *     <tr>
 208  *       <td>
 209  *              <code>DAY_OF_WEEK</code>
 210  *       </td>
 211  *       <td>
 212  *              <code>the first day of week</code>
 213  *       </td>
 214  *     </tr>
 215  *     <tr>
 216  *       <td>
 217  *              <code>WEEK_OF_MONTH</code>
 218  *       </td>
 219  *       <td>
 220  *              <code>0</code>
 221  *       </td>
 222  *     </tr>
 223  *     <tr>
 224  *       <td>
 225  *              <code>DAY_OF_WEEK_IN_MONTH</code>
 226  *       </td>
 227  *       <td>
 228  *              <code>1</code>
 229  *       </td>
 230  *     </tr>
 231  *     <tr>
 232  *       <td>
 233  *              <code>AM_PM</code>
 234  *       </td>
 235  *       <td>
 236  *              <code>AM</code>
 237  *       </td>
 238  *     </tr>
 239  *     <tr>
 240  *       <td>
 241  *              <code>HOUR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND</code>
 242  *       </td>
 243  *       <td>
 244  *              <code>0</code>
 245  *       </td>
 246  *     </tr>
 247  *   </tbody>
 248  * </table>
 249  * <br>Default values are not applicable for the fields not listed above.
 250  *
 251  * <p>
 252  * <strong>Example:</strong>
 253  * <blockquote>
 254  * <pre>
 255  * // get the supported ids for GMT-08:00 (Pacific Standard Time)
 256  * String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
 257  * // if no ids were returned, something is wrong. get out.
 258  * if (ids.length == 0)
 259  *     System.exit(0);
 260  *
 261  *  // begin output
 262  * System.out.println("Current Time");
 263  *
 264  * // create a Pacific Standard Time time zone


< prev index next >