It is hard to be OO when using a datetime object

It is hard to be OO when using a datetime object

Post by QmlsbE » Tue, 03 May 2005 17:34:03


I have a class that has as a member a datetime (birthdate). I try to
retrieve a value from a table.

Member.Birthdate = dsData.Tables(0).rows(0)("BirthDate")

works fine except when the birthdate in the table is null

so

If dsData.Tables(0).rows(0)("BirthDate") is DBNull.Value then
Member.BirthDate = ????????

I don't want to set the birthdate to the minvalue. I want it to be blank.
But a datetime will not allow a blank.

So what do I do?
 
 
 

It is hard to be OO when using a datetime object

Post by Cor Ligthe » Tue, 03 May 2005 18:18:57

Bill

What is this for type of value
Member.BirthDate

Cor

 
 
 

It is hard to be OO when using a datetime object

Post by QmlsbE » Tue, 03 May 2005 18:29:04

DateTime
 
 
 

It is hard to be OO when using a datetime object

Post by Jon Skeet » Tue, 03 May 2005 19:42:43


Well, you could easily write your own reference type which just
encapsulates DateTime.

--
Jon Skeet - < XXXX@XXXXX.COM >
http://www.yqcomputer.com/ ~skeet
If replying to the group, please do not mail me too
 
 
 

It is hard to be OO when using a datetime object

Post by Cor Ligthe » Tue, 03 May 2005 19:46:52

Bill

That is not a type that you can show, you have for that always to convert it
to a string, therefore it is in my opinion not from any importancy what the
nothing/null format is.

Just my thought,

Cor
 
 
 

It is hard to be OO when using a datetime object

Post by Jon Skeet » Tue, 03 May 2005 20:04:34


The best time to change things into a display format is just before you
want to display them though - that way you don't have to parse and
reformat the data every time you want to change or manipulate it.

Of course, in .NET 2.0 this will all be solved using nullable types.
Until then, I believe that using a class which just contains a DateTime
would be the best bet.

--
Jon Skeet - < XXXX@XXXXX.COM >
http://www.yqcomputer.com/ ~skeet
If replying to the group, please do not mail me too