< prev index next >
src/java.base/share/classes/java/time/format/DateTimeFormatter.java
Print this page
*** 148,164 ****
* Some applications may need to use the older {@link Format java.text.Format}
* class for formatting. The {@link #toFormat()} method returns an
* implementation of {@code java.text.Format}.
*
* <h3 id="predefined">Predefined Formatters</h3>
! * <table class="striped">
* <caption>Predefined Formatters</caption>
* <thead>
* <tr>
! * <th scope="col" style="text-align:left">Formatter</th>
! * <th scope="col" style="text-align:left">Description</th>
! * <th scope="col" style="text-align:left">Example</th>
* </tr>
* </thead>
* <tbody>
* <tr>
* <th scope="row">{@link #ofLocalizedDate ofLocalizedDate(dateStyle)} </th>
--- 148,164 ----
* Some applications may need to use the older {@link Format java.text.Format}
* class for formatting. The {@link #toFormat()} method returns an
* implementation of {@code java.text.Format}.
*
* <h3 id="predefined">Predefined Formatters</h3>
! * <table class="striped" style="text-align:left">
* <caption>Predefined Formatters</caption>
* <thead>
* <tr>
! * <th scope="col">Formatter</th>
! * <th scope="col">Description</th>
! * <th scope="col">Example</th>
* </tr>
* </thead>
* <tbody>
* <tr>
* <th scope="row">{@link #ofLocalizedDate ofLocalizedDate(dateStyle)} </th>
*** 274,333 ****
* LocalDate parsedDate = LocalDate.parse(text, formatter);
* </pre></blockquote>
* <p>
* All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The
* following pattern letters are defined:
! * <pre>
! * Symbol Meaning Presentation Examples
! * ------ ------- ------------ -------
! * G era text AD; Anno Domini; A
! * u year year 2004; 04
! * y year-of-era year 2004; 04
! * D day-of-year number 189
! * M/L month-of-year number/text 7; 07; Jul; July; J
! * d day-of-month number 10
! * g modified-julian-day number 2451334
! *
! * Q/q quarter-of-year number/text 3; 03; Q3; 3rd quarter
! * Y week-based-year year 1996; 96
! * w week-of-week-based-year number 27
! * W week-of-month number 4
! * E day-of-week text Tue; Tuesday; T
! * e/c localized day-of-week number/text 2; 02; Tue; Tuesday; T
! * F day-of-week-in-month number 3
! *
! * a am-pm-of-day text PM
! * h clock-hour-of-am-pm (1-12) number 12
! * K hour-of-am-pm (0-11) number 0
! * k clock-hour-of-day (1-24) number 24
! *
! * H hour-of-day (0-23) number 0
! * m minute-of-hour number 30
! * s second-of-minute number 55
! * S fraction-of-second fraction 978
! * A milli-of-day number 1234
! * n nano-of-second number 987654321
! * N nano-of-day number 1234000000
! *
! * V time-zone ID zone-id America/Los_Angeles; Z; -08:30
! * v generic time-zone name zone-name Pacific Time; PT
! * z time-zone name zone-name Pacific Standard Time; PST
! * O localized zone-offset offset-O GMT+8; GMT+08:00; UTC-08:00
! * X zone-offset 'Z' for zero offset-X Z; -08; -0830; -08:30; -083015; -08:30:15
! * x zone-offset offset-x +0000; -08; -0830; -08:30; -083015; -08:30:15
! * Z zone-offset offset-Z +0000; -0800; -08:00
! *
! * p pad next pad modifier 1
! *
! * ' escape for text delimiter
! * '' single quote literal '
! * [ optional section start
! * ] optional section end
! * # reserved for future use
! * { reserved for future use
! * } reserved for future use
! * </pre>
* <p>
* The count of pattern letters determines the format.
* <p>
* <b>Text</b>: The text style is determined based on the number of pattern
* letters used. Less than 4 pattern letters will use the
--- 274,337 ----
* LocalDate parsedDate = LocalDate.parse(text, formatter);
* </pre></blockquote>
* <p>
* All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The
* following pattern letters are defined:
! * <table class="striped">
! * <caption>Pattern Letters and Symbols</caption>
! * <thead>
! * <tr><th scope="col">Symbol</th> <th scope="col">Meaning</th> <th scope="col">Presentation</th> <th scope="col">Examples</th>
! * </thead>
! * <tbody>
! * <tr><th scope="row">G</th> <td>era</td> <td>text</td> <td>AD; Anno Domini; A</td>
! * <tr><th scope="row">u</th> <td>year</td> <td>year</td> <td>2004; 04</td>
! * <tr><th scope="row">y</th> <td>year-of-era</td> <td>year</td> <td>2004; 04</td>
! * <tr><th scope="row">D</th> <td>day-of-year</td> <td>number</td> <td>189</td>
! * <tr><th scope="row">M/L</th> <td>month-of-year</td> <td>number/text</td> <td>7; 07; Jul; July; J</td>
! * <tr><th scope="row">d</th> <td>day-of-month</td> <td>number</td> <td>10</td>
! * <tr><th scope="row">g</th> <td>modified-julian-day</td> <td>number</td> <td>2451334</td>
! *
! * <tr><th scope="row">Q/q</th> <td>quarter-of-year</td> <td>number/text</td> <td>3; 03; Q3; 3rd quarter</td>
! * <tr><th scope="row">Y</th> <td>week-based-year</td> <td>year</td> <td>1996; 96</td>
! * <tr><th scope="row">w</th> <td>week-of-week-based-year</td> <td>number</td> <td>27</td>
! * <tr><th scope="row">W</th> <td>week-of-month</td> <td>number</td> <td>4</td>
! * <tr><th scope="row">E</th> <td>day-of-week</td> <td>text</td> <td>Tue; Tuesday; T</td>
! * <tr><th scope="row">e/c</th> <td>localized day-of-week</td> <td>number/text</td> <td>2; 02; Tue; Tuesday; T</td>
! * <tr><th scope="row">F</th> <td>day-of-week-in-month</td> <td>number</td> <td>3</td>
! *
! * <tr><th scope="row">a</th> <td>am-pm-of-day</td> <td>text</td> <td>PM</td>
! * <tr><th scope="row">h</th> <td>clock-hour-of-am-pm (1-12)</td> <td>number</td> <td>12</td>
! * <tr><th scope="row">K</th> <td>hour-of-am-pm (0-11)</td> <td>number</td> <td>0</td>
! * <tr><th scope="row">k</th> <td>clock-hour-of-day (1-24)</td> <td>number</td> <td>24</td>
! *
! * <tr><th scope="row">H</th> <td>hour-of-day (0-23)</td> <td>number</td> <td>0</td>
! * <tr><th scope="row">m</th> <td>minute-of-hour</td> <td>number</td> <td>30</td>
! * <tr><th scope="row">s</th> <td>second-of-minute</td> <td>number</td> <td>55</td>
! * <tr><th scope="row">S</th> <td>fraction-of-second</td> <td>fraction</td> <td>978</td>
! * <tr><th scope="row">A</th> <td>milli-of-day</td> <td>number</td> <td>1234</td>
! * <tr><th scope="row">n</th> <td>nano-of-second</td> <td>number</td> <td>987654321</td>
! * <tr><th scope="row">N</th> <td>nano-of-day</td> <td>number</td> <td>1234000000</td>
! *
! * <tr><th scope="row">V</th> <td>time-zone ID</td> <td>zone-id</td> <td>America/Los_Angeles; Z; -08:30</td>
! * <tr><th scope="row">v</th> <td>generic time-zone name</td> <td>zone-name</td> <td>Pacific Time; PT</td>
! * <tr><th scope="row">z</th> <td>time-zone name</td> <td>zone-name</td> <td>Pacific Standard Time; PST</td>
! * <tr><th scope="row">O</th> <td>localized zone-offset</td> <td>offset-O</td> <td>GMT+8; GMT+08:00; UTC-08:00</td>
! * <tr><th scope="row">X</th> <td>zone-offset 'Z' for zero</td> <td>offset-X</td> <td>Z; -08; -0830; -08:30; -083015; -08:30:15</td>
! * <tr><th scope="row">x</th> <td>zone-offset</td> <td>offset-x</td> <td>+0000; -08; -0830; -08:30; -083015; -08:30:15</td>
! * <tr><th scope="row">Z</th> <td>zone-offset</td> <td>offset-Z</td> <td>+0000; -0800; -08:00</td>
! *
! * <tr><th scope="row">p</th> <td>pad next</td> <td>pad modifier</td> <td>1</td>
! *
! * <tr><th scope="row">'</th> <td>escape for text</td> <td>delimiter</td> <td></td>
! * <tr><th scope="row">''</th> <td>single quote</td> <td>literal</td> <td>'</td>
! * <tr><th scope="row">[</th> <td>optional section start</td> <td></td> <td></td>
! * <tr><th scope="row">]</th> <td>optional section end</td> <td></td> <td></td>
! * <tr><th scope="row">#</th> <td>reserved for future use</td> <td></td> <td></td>
! * <tr><th scope="row">{</th> <td>reserved for future use</td> <td></td> <td></td>
! * <tr><th scope="row">}</th> <td>reserved for future use</td> <td></td> <td></td>
! * </tbody>
! * </table>
* <p>
* The count of pattern letters determines the format.
* <p>
* <b>Text</b>: The text style is determined based on the number of pattern
* letters used. Less than 4 pattern letters will use the
< prev index next >