Struts 2 Date Format Examples

In this tutorial you will learn about Date Format function in Struts 2. We have provided fully tested example code to illustrate the concepts. You can copy the code and use it for your fast development.

Struts 2 Date Format Examples

In this tutorial you will learn about Date Format function in Struts 2. We
have provided fully tested example code to illustrate the concepts. You can copy
the code and use it for your fast development.

Struts Date tag

Struts date tag is used to output the date into required format. It can be
used to format the date into several different formats. Syntax of the date tag
is:

<s:date name="todayDate" format="yyyy-MM-dd" />

Parameters

Following table shows the parameters of date tag.

Name

Required

Default

Evaluated

Type

Description

format

false

false

String

The date format pattern

id

false

true

String

It will be used id tag in the HTML

name

true

true

String

The date value which is to be formatted

nice

false

false

true

Boolean

Whether to print out the date nicely

The nice format is very interesting. The following table shows,
how it
will format the date output: