• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Global date format for JSF

 
John Burton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have dates all over the site that need to be formatted. Instead of going to each date and formatting it with the convertDateTime tag, is there a way I can just globally change the format of how it displays dates? If they change their mind on formatting and I would be stuck going through the entire site changing every one of them.

There seems like an easier way.
 
Tim Holloway
Saloon Keeper
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Jonny Bingo"

I can give you a detailed answer, although I doubt it will make you happy.

First, however, you need to change your display name to conform to our Naming Requirements (http://www.javaranch.com/name.jsp).

We don't have a lot of rules here at the JavaRanch, but that's one of the few we insist on.
 
John Burton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I did do that worked is create a variable in a application scoped bean that just holds some global variables. It contains the date format and I call it from the formatDateTime tag like



I am curious as to what your answer was. A better solution?

 
Tim Holloway
Saloon Keeper
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's about as good as it gets. You can keep the conversion pattern in a session bean if you want to be able to customize it on a per-person basis, but the same tactic applies.

The timezone for JSF conversion unless overridden is GMT and cannot be overriden globally. The formatting pattern employed is the default locale pattern for the JVM that runs the webapp (I think). So the only way to achieve specific zones and formats is on a per-use basis.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic