I have a design issue I'm facing, I bring it up here so maybe I can get more ideas.
Currently in my project, I have a scenario where I need to represent the age of children.
The age can be from 0 to 15. from age 1 to 15 it's easy, I can store it as an integer, but the problem is if the age is between 0 and 1. Then I want to store it in months.
Storing the age as a java.util.Date
won't work because I don't want to do comparison with the current date (I'm dealing with a really big database). regarding floating point, well you know that there are 12 months in one year, so then I need to to translate 0.5 to six months and 0.7 to I don't know...
I'm looking for a good way to store the age in one type. It can be Enum
, etc.
It should be small as possible. and it should be possible to persist the type in a database without any issues...
You could always store the age in an appropriate small unit (e.g. months), and convert it to years when you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With