Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EL help  RSS feed

 
sue raj
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newbie to EL. I have a java bean class A that has a Date field dateFieldB which is stored in simple date format (yyyy-mm-dd hh:mm:ss).
In my jsp page, I have something like ${idA.dateFieldB }. I would like to use java Date functions like getHours(). Please forgive my ignorance but I did something like ${idA.dateFieldB.getHours() } and it gave an error "The function getHours must be used with a prefix when a default namespace is not specified".

Can someone suggest as to how I could get hours, minutes and seconds from this date field in this jsp page. Thanks,


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sue raj wrote:I am a newbie to EL. I have a java bean class A that has a Date field dateFieldB which is stored in simple date format (yyyy-mm-dd hh:mm:ss).

That doesn't make sense. Dates aren't stored in a specific format; dates are just values. So is the property (not "field") a java.util.Date or a String? If the former, then there is no format.

In my jsp page, I have something like ${idA.dateFieldB }. I would like to use java Date functions like getHours(). Please forgive my ignorance but I did something like ${idA.dateFieldB.getHours() }

You can't ever call methods on a bean. You can only access properties. If (see my question above) dateFieldB is a java.util.Date, then you can access its hours property via ${idA.dateFieldB.hours}.

If you are going to be working with beans, it's important to learn about bean properties and how they are accessed.

Caveat: be aware that the getHours() accessor for the hours property is a deprecated method. Relying upon it may cause future problems.
 
sue raj
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!