This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes convertDateTime seconds??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "convertDateTime seconds???" Watch "convertDateTime seconds???" New topic
Author

convertDateTime seconds???

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I have that, to convert my Date-Object into a Local-sensitive manner:



The output:



BUT I need the seconds, tooo!

When I print this out without converter:





But I need the converter and cannot use a pattern as when using a pattern, I guess, the Local-sensitivity does not work.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
nimo frey wrote:But I need the converter and cannot use a pattern as when using a pattern, I guess, the Local-sensitivity does not work.

Guess? This makes no sense. Just use a pattern.
Piotr Swiecicki
Greenhorn

Joined: Nov 16, 2006
Posts: 17


Have you tried dateStyle="full" instead?
http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
Tried it with long, tried it with full:

<f:convertDateTime type="both" dateStyle="full"/>

but no seconds visible.

Using a pattern such as: <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/>

works but then it will prints it to that string for ALL Locales !!

I do not understand why dateStyle="full" does not print the seconds.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
nimo frey wrote:Tried it with long, tried it with full:

<f:convertDateTime type="both" dateStyle="full"/>

but no seconds visible.

Using a pattern such as: <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/>

works but then it will prints it to that string for ALL Locales !!
Oh, you want a locale dependent format? OK then

I do not understand why dateStyle="full" does not print the seconds.

Maybe your locale doesn´t "allow" that. Also see the aforementioned javadoc of DateFormat. Here´s an extract of relevance:

... You can pass in different options to these factory methods to control the length of the result; from SHORT to MEDIUM to LONG to FULL. The exact result depends on the locale, but generally ...

So, either life with it or use a fixed pattern.
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
The exact result depends on the locale




aha. so my browser says me: "Hey, you are not allowed to see the seconds!"

aha..okay.

I use my pattern. thanks:-)
 
Consider Paul's rocket mass heater.
 
subject: convertDateTime seconds???
 
Similar Threads
h:dataTable and rich:toolTip
Tomawak inputCalendar Tag malfunction
Rich:Datatable rerendering problem
Using simultaneously Converters
MyFaces-Date/TimeZone Issue?