Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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:-)
 
ice is for people that are not already cool. Chill with this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic