< prev index next >

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

Print this page




 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");




 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 scope="col">
 167  *          Field
 168  *       </th>
 169  *       <th scope="col">
 170             Default Value
 171  *       </th>
 172  *     </tr>
 173  *   </thead>
 174  *   <tbody>
 175  *     <tr>
 176  *       <th scope="row">
 177  *              <code>ERA</code>
 178  *       </th>
 179  *       <td>
 180  *              <code>AD</code>
 181  *       </td>
 182  *     </tr>
 183  *     <tr>
 184  *       <th scope="row">
 185  *              <code>YEAR</code>
 186  *       </th>
 187  *       <td>
 188  *              <code>1970</code>
 189  *       </td>
 190  *     </tr>
 191  *     <tr>
 192  *       <th scope="row">
 193  *              <code>MONTH</code>
 194  *       </th>
 195  *       <td>
 196  *              <code>JANUARY</code>
 197  *       </td>
 198  *     </tr>
 199  *     <tr>
 200  *       <th scope="row">
 201  *              <code>DAY_OF_MONTH</code>
 202  *       </th>
 203  *       <td>
 204  *              <code>1</code>
 205  *       </td>
 206  *     </tr>
 207  *     <tr>
 208  *       <th scope="row">
 209  *              <code>DAY_OF_WEEK</code>
 210  *       </th>
 211  *       <td>
 212  *              <code>the first day of week</code>
 213  *       </td>
 214  *     </tr>
 215  *     <tr>
 216  *       <th scope="row">
 217  *              <code>WEEK_OF_MONTH</code>
 218  *       </th>
 219  *       <td>
 220  *              <code>0</code>
 221  *       </td>
 222  *     </tr>
 223  *     <tr>
 224  *       <th scope="row">
 225  *              <code>DAY_OF_WEEK_IN_MONTH</code>
 226  *       </th>
 227  *       <td>
 228  *              <code>1</code>
 229  *       </td>
 230  *     </tr>
 231  *     <tr>
 232  *       <th scope="row">
 233  *              <code>AM_PM</code>
 234  *       </th>
 235  *       <td>
 236  *              <code>AM</code>
 237  *       </td>
 238  *     </tr>
 239  *     <tr>
 240  *       <th scope="row">
 241  *              <code>HOUR, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND</code>
 242  *       </th>
 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");


< prev index next >