YouTip LogoYouTip

Jstl Format Formatdate Tag

[![Image 1: JSP Standard Tag Library](#)JSP Standard Tag Library](#) The tag is used to format dates in different ways. ### Syntax <fmt:formatDate value="" type="" dateStyle="" timeStyle="" pattern="" timeZone="" var="" scope=""/> ### Attributes The tag has the following attributes: | Attribute | Description | Required | Default Value | | --- | --- | --- | --- | | value | The date to be displayed | Yes | None | | type | DATE, TIME, or BOTH | No | date | | dateStyle | FULL, LONG, MEDIUM, SHORT, or DEFAULT | No | default | | timeStyle | FULL, LONG, MEDIUM, SHORT, or DEFAULT | No | default | | pattern | Custom format pattern | No | None | | timeZone | The time zone for displaying the date | No | Default time zone | | var | The variable name to store the formatted date | No | Displayed on the page | | scope | The scope of the variable storing the formatted date | No | page | Tag Format Patterns | Code | Description | Example | | --- | --- | --- | | G | Era designator | AD | | y | Year. If the year without the era is less than 10, the year is displayed without a leading zero. | 2002 | | M | Month in year. Months without a leading zero for single-digit months. | April & 04 | | d | Day in month. Days without a leading zero for single-digit days. | 20 | | h | Hour in A.M./P.M. (1-12). Hours without a leading zero for single-digit hours. | 12 | | H | Hour in day (0-23). Hours without a leading zero for single-digit hours. | 0 | | m | Minute in hour. Minutes without a leading zero for single-digit minutes. | 45 | | s | Second in minute. Seconds without a leading zero for single-digit seconds. | 52 | | S | Millisecond | 970 | | E | Day in week | Tuesday | | D | Day in year | 180 | | F | Day of week in month | 2 (Second Wednesday in the month) | | w | Week in year | 27 | | W | Week in month | 2 | | a | A.M./P.M. marker | PM | | k | Hour in day (1-24) | 24 | | K | Hour in A.M./P.M. (0-11) | 0 | | z | Time zone | Central Standard Time | | ' | Escape for text | Delimiter | | '' | Single quote | ' | * * * ## Example JSTL fmt:dateNumber Tag

Date Formatting:

<c:set var="now" value="" />

Date Formatting (1):

Date Formatting (2):

Date Formatting (3):

Date Formatting (4):

Date Formatting (5):

Date Formatting (6):

Date Formatting (7):

The output of the above example: Date Formatting:Date Formatting (1): 11:19:43Date Formatting (2): 2016-6-26Date Formatting (3): 2016-6-26 11:19:43Date Formatting (4): 16-6-26 11:19 AMDate Formatting (5): 2016-6-26 11:19:43Date Formatting (6): June 26, 2016 11:19:43 AMDate Formatting (7): 2016-06-26 * * JSP Standard Tag Library](#)
← Jstl Format Parsedate TagJstl Format Parsenumber Tag β†’