messing with Time

  • Thread starter Thread starter Sharon
  • Start date Start date
S

Sharon

What will be the best class for time representation?

i need simple interaction ( convert string to time , get time ...)

format time : "08:00" "22:09"



is DataTime the best class for me ?

should I write my own Code ?



Thank you

Sharon
 
Use DateTime, although it is not a class but a struct. You need not worry
about the date portion if all you care about is the time, but it will be
there none the less. The reason to use this is that it is more easily
transmitted to/from a database such as SQL Server rather than rolling your
own class.

JIM
 
It's almost always best to go with something already written, debugged
*and* standardized, rather than trying the write & debug your own
proprietary solution.

The only trick with using DateTime is to remember to filter out the date
portion when you output the time:

DateTime dt = DateTime.Parse("08:00");
Console.WriteLine("{0:t}", dt);

Displays: "8:00 AM"
 
Back
Top