<netui:formatDate> Tag
A formatter used to format dates.
<netui:formatDate
[country="country"]
[language="language"]
[pattern="pattern"]
[stringInputPattern="stringInputPattern"] />
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 |
Required: No | Supports
runtime evaluation: Yes | Data bindable: |
|
|
language |
Required: No | Supports
runtime evaluation: Yes | Data bindable: |
|
|
pattern |
Required: No | Supports
runtime evaluation: Yes | Data bindable: |
|
|
stringInputPattern |
Required: No | Supports
runtime evaluation: Yes | Data bindable: |
|
The pattern used to convert a String value into a date. |
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>