Thanks guys But what if I already have a table with a date column (not long) - Should I hold java.util.Date in the VO and convert it to java.sql.Date in the DAO?
Rivka -----Original Message----- From: Gareth Evans [mailto:[EMAIL PROTECTED] Sent: Thursday, August 25, 2005 12:28 PM To: Struts Users Mailing List Subject: Re: basic date field question A slight tweak to that... StudentVO(){ private Date birthDate; public long getBirthDate() { return birthDate.getTime(); } public java.util.Date getBirthDateAsDate(){ return birthDate; } Why? Because this way two subsequent calls to 'getBirthDateAsDate' will return the same object i.e. You can then modify the date using a calendar and the correct values within the StudentVO object will be updated. Gareth Leon Rosenberg wrote: > On Thu, 2005-08-25 at 12:34 +0200, Rivka Shisman wrote: > >>Hi friends >> > > > Shalom, > > >> >> >>I'm puzzled with a basic design problem: >> >> >> >>I have a VO - say StudentVO - that has a property -> birth_date. >> >> >> >>Should the birth_date property be of type String (and then in the DAO >>convert it to java.sql.Date) - > > > > The value object should have business knowledge, and therefor usage of > the string isn't quite appropriate. > On the other hand, java.sql.Date is a rather ugly thing. Personally I > prefer to store date variables as longs in milliseconds, it's most > easier to work with, calculating date intervals is quite easy, and you > can convert it to a java.util.Date anytime. > > So, my proposal would be: > StudentVO(){ > private long birthDate; > > public long getBirthDate(); > > public java.util.Date getBirthDateAsDate(){ > return new Date(getBirthDate()); //or do it with calendar, or whatever. > } > > > In your db you should store it as long then. > > regards > Leon > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- Gareth Evans MSoft eSolutions Limited Technology Centre Inward Way Rossmore Business Park Ellesmere Port Cheshire CH65 3EN -- Tel: +44 (0)870 0100 704 Fax: +44 (0)870 9010 705 E-Mail: [EMAIL PROTECTED] Web: www.msoft.co.uk ---------------------------------------------- Terms: Please note that any prices quoted within this e-mail are subject to VAT. All program details and code described in this e-mail are subject to copyright (c) of MSoft eSolutions Limited and remain the intellectual property of MSoft eSolutions Limited. Any proposal or pricing information contained within this e-mail are subject to MSoft eSolutions' Terms and Conditions ---------------------------------------------- Disclaimer: This message is intended only for use of the addressee. If this message was sent to you in error, please notify the sender and delete this message. MSoft eSolutions Limited cannot accept responsibility for viruses, so please scan attachments. Views expressed in this message do not necessarily reflect those of MSoft eSolutions Limited who will not necessarily be bound by its contents. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]