views:

48

answers:

2

In the application I am currently writing the specification asks that a number of dates are entered without years. I want to know everyone opinion of the best way of doing this, at all levels.

I am almost certain that they should be stored in the DB as normal Date fields, However before they get here, the year should always be set to the same thing (maybe 1900 or something equally obvious).

My domain model is giving me a few problems. Do I create a new type that handles dates without years? Do I use standard DateTimes but intercept the setter to ensure that the year is always reset? is there some other option?

What about the UI. Currently we use JQuery UI for our datetime fields. Can this be adjusted to make it year independent? is there a better way of doing it?

+1  A: 

Leave the year part of datetime just be. Simply ignore it in all your read/write operations.

If you need however to perform distance calculations on dates, just set it to same fixed values. Better do this in your framework so that this part is handled automatically and is transparent to you.

Developer Art
+1  A: 

Your parameters should be DateTime type or just Date type. Try to manipulate with get{} and set{}, to have both year values set to one exact value. This modification will not affect your application and it will be easy to manipulate in the future.

ZokiManas