What attribute type should I use to keep day and month, NOT year?

I need a java class with several attributes that must have day and month (june 5. july 8, etc). What is the best way to define this field?

The type day of year will have problems with leap years, and dividing the attribute into day and month will make me have a lot of them (since I need several of these) so is there another approach to this field?

Also: I use MySql for persistance, so I want attributeseasy to persist.


Two options:

  1. You can split your data in two fields: dayNumber and monthNumber, and store them in your MySQL database as two tinyInt fields.
  2. You can store the data as a char array (4 entries) in Java, and store the value in a Char(4) field in MySQL

I would personally go with option 1

Leave a Reply

Your email address will not be published. Required fields are marked *