• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

convertDateTime seconds???

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Have you tried dateStyle="full" instead?
http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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:-)
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic