# <netui:formatDate> Tag

A formatter used to format dates.

## Syntax

<netui:formatDate
[country="string_country"]
[language="string_language"]
[pattern="string_simpleDataFormat"]
[stringInputPattern="string_stringInputPattern"] />

## Description

A formatter used to format dates. This formatter uses patterns that conform to java.text.SimpleDateFormat pattern syntax. Valid types for formatting are:

> - String
> - java.sql.Date
> - java.util.Date
> - java.util.Calendar

The <netui:formatDate> tag formats the output of its parent tag. For example:

        <netui:content value="{pageContext.euroDate}">
            <netui:formatDate pattern="dd-MM-yyyy" />
        </netui:content>

The following table summarizes the pattern letters that can be used.

Letter | Date or Time Component | Examples
--- | --- | ---
`G` | Era designator | `AD`
`y` | Year | `1996`; `96`
`M` | Month in year | `July`; `Jul`; `07`
`w` | Week in year | `27`
`W` | Week in month | `2`
`D` | Day in year | `189`
`d` | Day in month | `10`
`F` | Day of week in month | `2`
`E` | Day in week | `Tuesday`; `Tue`
`a` | Am/pm marker | `PM`
`H` | Hour in day (0-23) | `0`
`k` | Hour in day (1-24) | `24`
`K` | Hour in am/pm (0-11) | `0`
`h` | Hour in am/pm (1-12) | `12`
`m` | Minute in hour | `30`
`s` | Second in minute | `55`
`S` | Millisecond | `978`
`z` | Time zone | `Pacific Standard Time`; `PST`; `GMT-08:00`
`Z` | Time zone | `-0800`

The number of pattern letters used determines the final presentation. For example, yy specifies a 2 digit year, while yyyy specifies a four digit year. For detailed information see java.text.SimpleDateFormat .

If the input type is a String, <netui:formatDate> attempts to convert the String into a java.util.Date object before formatting. For the conversion to succeed, the String must conform to a format listed below.

The valid formats are:

> - MM/dd/yy
> - yyyy-MM-dd
> - MMddyy
> - the local default

## Attributes

country | Determines a formatting style for the specified country. The `country` attribute takes an uppercase, two letter code as defined by ISO-3166. For a list of country codes see ISO-3166 Country Codes
Required | Supports runtime expression evaluation | Data bindable
No | No | No
language | Determines a formatting style for the specified language. The `language` attribute is optional, but it must be set when the `country` attribute is set. The `language` attribute takes a lowercase, two letter code as defined by ISO-639. For a list of language codes see ISO-639 Language Codes
Required | Supports runtime expression evaluation | Data bindable
No | No | No
pattern | The pattern used to format the input. For detailed information on pattern syntax see java.text.DecimalFormat .
Required | Supports runtime expression evaluation | Data bindable
No | No | Read Only
stringInputPattern | The pattern used to convert a String value into a date.
Required | Supports runtime expression evaluation | Data bindable
No | No | Read Only

## Sample

In this sample, the <netui:label> tag's output will be formatted to something like 08/29/1957.

        <netui:label value="{pageContext.today}">
            <netui:formatDate pattern="MM/dd/yyyy" />
        </netui:label>

## Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/formatTags/index.jsp

## Related Topics

<netui:format...> Tag Samples

<netui:formatNumber> Tag

<netui:formatString> Tag

java.text.NumberFormat