Is it possible to change default formatting of Date object in JSP pages? Now I have some kind of formatting and I would like to change formatting without using fmt-tags, because that would mean I would have to type that formatting to all pages and there are many!
Share
Best is to create your own custom taglib which does exactly the same as JSTL
fmt:formatDate.But why would you want to reinvent the wheel? Is it the “much” effort of replacing the code in JSP? Well, that’s just your job 🙂 It’s basically as simple as following:
/WEB-INF/lib.Declare
fmttaglib in top of your JSP:Use
fmt:formatDateon any bean’sjava.util.Dateproperty.Above example will print today’s date as
10/01/25for English locales and for example25.01.10for German locales. No worries anymore! 🙂You would be almost already finished in the time you spent asking the question and waiting the answer 😉