org.springframework.format.datetime

## 类 DateFormatter

- java.lang.Object
- - org.springframework.format.datetime.DateFormatter

- 所有已实现的接口:
    Formatter<Date>, Parser<Date>, Printer<Date>

      public class DateFormatter
      extends Object
      implements Formatter<Date>

  A formatter for `Date` types. Allows the configuration of an explicit date pattern and locale.
  从以下版本开始:
    3.0
  作者:
    Keith Donald, Juergen Hoeller, Phillip Webb
  另请参阅:
    `SimpleDateFormat`

- - ### 构造器概要

    构造器
    构造器和说明
    `DateFormatter()` Create a new default DateFormatter.
    `DateFormatter(String pattern)` Create a new DateFormatter for the given date pattern.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected DateFormat` | `getDateFormat(Locale locale)`
    `Date` | `parse(String text, Locale locale)` Parse a text String to produce a T.
    `String` | `print(Date date, Locale locale)` Print the object of type T for display.
    `void` | `setIso(DateTimeFormat.ISO iso)` Set the ISO format used for this date.
    `void` | `setLenient(boolean lenient)` Specify whether or not parsing is to be lenient.
    `void` | `setPattern(String pattern)` Set the pattern to use to format date values.
    `void` | `setStyle(int style)` Set the style to use to format date values.
    `void` | `setStylePattern(String stylePattern)` Set the two character to use to format date values.
    `void` | `setTimeZone(TimeZone timeZone)` Set the TimeZone to normalize the date values into, if any.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### DateFormatter

          public DateFormatter()

      Create a new default DateFormatter.

    - #### DateFormatter

          public DateFormatter(String pattern)

      Create a new DateFormatter for the given date pattern.

  - ### 方法详细资料

    - #### setPattern

          public void setPattern(String pattern)

      Set the pattern to use to format date values.

      If not specified, DateFormat's default style will be used.

    - #### setIso

          public void setIso(DateTimeFormat.ISO iso)

      Set the ISO format used for this date.
      参数:
        `iso` - the `DateTimeFormat.ISO` format
      从以下版本开始:
        3.2

    - #### setStyle

          public void setStyle(int style)

      Set the style to use to format date values.

      If not specified, DateFormat's default style will be used.

      另请参阅:
        `DateFormat.DEFAULT`, `DateFormat.SHORT`, `DateFormat.MEDIUM`, `DateFormat.LONG`, `DateFormat.FULL`

    - #### setStylePattern

          public void setStylePattern(String stylePattern)

      Set the two character to use to format date values. The first character used for the date style, the second is for the time style. Supported characters are
      - 'S' = Small
      - 'M' = Medium
      - 'L' = Long
      - 'F' = Full
      - '-' = Omitted
      This method mimics the styles supported by Joda-Time.
      参数:
        `stylePattern` - two characters from the set {"S", "M", "L", "F", "-"}
      从以下版本开始:
        3.2

    - #### setTimeZone

          public void setTimeZone(TimeZone timeZone)

      Set the TimeZone to normalize the date values into, if any.

    - #### setLenient

          public void setLenient(boolean lenient)

      Specify whether or not parsing is to be lenient. Default is false.

      With lenient parsing, the parser may allow inputs that do not precisely match the format. With strict parsing, inputs must match the format exactly.

    - #### print

          public String print(Date date,
                              Locale locale)

      从接口复制的说明: `Printer`
      Print the object of type T for display.
      指定者:
        `print` 在接口中 `Printer<Date>`
      参数:
        `date` - the instance to print
        `locale` - the current user locale
      返回:
        the printed text string

    - #### parse

          public Date parse(String text,
                            Locale locale)
                     throws ParseException

      从接口复制的说明: `Parser`
      Parse a text String to produce a T.
      指定者:
        `parse` 在接口中 `Parser<Date>`
      参数:
        `text` - the text string
        `locale` - the current user locale
      返回:
        an instance of T
      抛出:
        `ParseException` - when a parse exception occurs in a java.text parsing library

    - #### getDateFormat

          protected DateFormat getDateFormat(Locale locale)