• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

getting Date out with JSTL

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd like to be able to check via JSTL fmt library the time of the day, (say if it is 2 pm or not) and attach html tags based on output of the test. For some reason I'm not getting any errors or the date out when I do the following:

Could someone tell me please what I'm missing from the above?...I do import the fmt library.
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<fmt:formatDate type="both" dateStyle="default" timeStyle="default" value="${now}" />
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still not getting anything out. I declare var now as follows:

and I access it (as suggested above), but no date is shown. Since I need time of the date, maybe there is a way of getting just the time?
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
got it, works now!
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by liliya woland:
maybe there is a way of getting just the time?



If now is a Date, why are you messing around with parseDate?

You have a copy of the JSTL Spec handy, right? Look up formatDate and see what it has that can help you.

Hint: also look up java.text.DateFormat
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I did clean up the jstl code and now I do get the time only. I'm doing this to test if it is 2pm. I'd like to be able to do this using jstl notation, although writing a scriplet will probably be faster.
I'd like to have a test that would do something as below, but don't know if this is at all possible via jstl.

Thank you in advance.
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you look at formatDate as I suggested?
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I got the time out of it with

I actually found my old java code for getting all the info I need (hour,ampm), so I think I'm going with a scriptlet and plain java code - takes much less time.
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by liliya woland:
so I think I'm going with a scriptlet and plain java code - takes much less time.



Not the best of attitudes.

Here's the way:



The secret is in knowing how to use the pattern attribute.
[ April 18, 2007: Message edited by: Bear Bibeault ]
reply
    Bookmark Topic Watch Topic
  • New Topic