File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes fmt:formatDate with an Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "fmt:formatDate with an "en" locale formats like "en_US"" Watch "fmt:formatDate with an "en" locale formats like "en_US"" New topic
Author

fmt:formatDate with an "en" locale formats like "en_US"

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
I thought the following JSP snippet would print out the date formatted according to German, English (UK) and English (US) custom. But English (UK) is "8/2/2006" -just like en_US- when I was expecting the day to come before the month. Isn't that the UK custom, or am I misunderstanding how date formatting works in JSTL?



Result:


[ August 02, 2006: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60761
    
  65

What's the locale that your browser is set to?

What happens if you are explicit with "en_UK"?
[ August 02, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
en_UK does the same as en_US and en.

According to the JSTL docs the browser settings are ignored if fmt:setLocale is used, and that's indeed what's happening (i.e., the accepted languages don't make a difference).
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60761
    
  65

Hmm, I'll guess I'll have to let our UK bretheren weigh in on whether the date format is correct or not.
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
Try "en_GB" as the locale string.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
Thanks Stefan. en_GB works fine (it produces "03/08/06").

Somehow I was under the impression that "en" would default to UK usage, but apparently it defaults to US usage.
[ August 03, 2006: Message edited by: Ulf Dittmer ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fmt:formatDate with an "en" locale formats like "en_US"
 
Similar Threads
fmt:parseDate with SQL Date
formatDate issue
Date and Timestamp comparison
getting Date out with JSTL
fmt:setLocale problem