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]

Reply via email to