Date and time are important matters in internationalized web applications. Different country has it own way to present date and time in different format. JSP has an action called to allow you to format date and time based on a specificlocale. Here is a table of action attributes. As you can see only value attribute isrequired for action.
Date and time are important matters in internationalized web applications. Different country has it own way to present date and time in different format. JSP has an action called to allow you to format date and time based on a specificlocale. Here is a table of action attributes. As you can see only value attribute is required for action.
Name | Mandatory | Meaning | ||
---|---|---|---|---|
value | yes | Date and/or time value to be formatted. | ||
type | no | Accept date or/and time to be used to format | ||
dateStyle | no | Specify predefined formatted style for date only if date value is used for formatting. | ||
timeStyle | no | Specify predefined formatted style for time only if time value is used for formatting. | ||
pattern | no | Specify standard customized pattern for formating date and/or time | ||
timeZone | no | If the time value is used to format, this attribute specify time zone for that time value. | ||
var | no | This attribute is for exporting scoped variable which stores the formatted date and/or time as a string | ||
scope | no | specify the scope of var. |
First we use the useBean tag to initialize a scoped variable called now and store current date value into this variable. Then we set the locale to different locales: US and FR and print out the current date in now variable by using action.
Formatting Date and/or Time
By default format and print only date. If you want to print time or bothdate and time you can use the type attribute. The type attribute accepts date, time and both to allow you to print such a this information in a specific locale. Let's take a look at an example:
Formatting Date Time with predefined styles and custom patterns
You cannot only format and print date & time with predefined styles provided by JSTL but also with a custom pattern. The timeStyle and dateStyle attributes of specify the predefined styles you want to format. Patterns attribute enables you to define your own style. In this case, you need the date & time code table bellow to find exactly what you want to format.
Code | Meaning |
---|---|
G | The era (A.D., B.C., and so on) |
y | The year (yy for two-digit years, yyyy for four digits) |
M | The month (MM for numeric month, MMM or longer for month names orabbreviations) |
w | The week of the year (ww for two digits) |
W | The week of the month |
D | The day of the year (DDD for three digits) |
d | The day of the month (dd for two digits) |
F | The numeric day of the week |
E | The text day of the week (EEEE or longer for full name) |
a | AMa.m./PMp.m. indicator |
H | Hour of the day (0–23) |
k | Hour of the day (1–24) |
K | Hour in a.m./p.m. (0–11) |
h | Hour in a.m./p.m. (1–12) |
m | Minutes in hour |
s | Seconds in minute |
S | Milliseconds in second |
z | Full time zone name |
Z | RFC 822 time zone (for example, 0500) |
9 comments:
Well I am so excited that I have found your post because I have been searching for some information on this for almost three hours! You've helped me a lot indeed and by reading this article I have found many new and useful information about this subject! http://scarprinnow.com
Thanks for the post and information! I think education is important for us so we must prepare the best education for our generation by sharing such great information with each other!
http://celabright.info
I have to say this post was certainly informative and contains useful content for enthusiastic visitors. I will definitely bookmark this blog for future reference and further viewing. Thanks a bunch for sharing this with us!
www.fadeplex.com
I came to this page by searching Yahoo. I have found it quite interesting. Thank you for providing this. I will have to visit here again!
we buy houses
I appreciate the work of all people who share information with others. Great Blog! Great post about this. I am sure my visitors will find that very useful. This is an interesting and so well maintained blog. Whole article is too good and well written.
Houston plastic surgeon
Really enjoyed reading this. Thank you for sharing this valuable information with us. I have bookmarked this site and will be sure to check for updates.
latest indian sarees
i do pretty much the exact same thing, local vhosts and all. taking nightly backups of /home is easy with rsync, so when anything goes awry, i just pull down the folder from my vps. since the cronjob itself is in the folder, even my backup script gets backed up. what ide do you use?
This is such an informative article and very clearly written. Every single thought and idea is direct to the point. Perfectly laid out. Thank you for taking your time sharing this to you readers.
Fast House Sale San Antonio
I adore what you have got right here. You make it entertaining and you still manage to keep it smart.This is truly a great blog thanks for sharing
Post a Comment