• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

date conversion problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

im using struts2,hibernate3.2 and java1.5 in my application.In the jsp,im taking date in the textfield i.e
<s:textfield name="obEIOutageBean.date" id="todays_date" value="%{obEIOutageBean.date}" />
In hibernate mapping file this property is like
<property name="date" column="OUTAGE_DATE" type="java.util.Date"/>
In the bean it is, java.utl.Date
when im giving the date value in the jsp, it is not setting to the bean. Is there any conversions required?. format of date is "DD/MM/YYYY". where i make this converion i.e compatible for retieving and storing the record.
i was stuck with this, if any one knows help me. thanks in advance.

Regards,
Ravi
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ravi

First you can check with jsp how will you the format then convert to bean side,


suppose you are giving in the format of dd/mm/yyyy (31/12/2007)

In the bean you will use the format like

java.text.DateFormat de = new java.text.DateFormat("dd/mm/yyyy);
java.text.DateFormat def = new java.text.DateFormat("yyyy-mm-dd");

client object obj contained the date like 31/12/2007

In the bean you will assign beanobj like def.format(de.parse(clientobject)));

Try and tell me your feedback

Because in the database defaultly take format like yyyy-mmd-dd.



Regards

k.krishnamoorthy.
 
ravi pamuru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi krishnamoorthy,

In the jsp page, im taking it as <s:textfield> and in the bean im taking as
java.util.Date. The value is not going to set into the bean. Then how can i set the value into the bean. Is there any possibility, by using <s ate> tag. I don't know how it is actually working. Thanks for your reply.

regards,
Ravi
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the struts forum, this is not an ORM question.

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic