Christian Lisangola Christian Lisangola - 14 days ago 5
Java Question

Creating only month and year column in mysql database

I'm creating a little program with Java.In the date field which is a combobox for selecting only month and date as

02/2016
.Is there a way to record this date format in mysql in a mm/yy field only?

Answer

Instead of storing it in this format, maybe the best approach is to store it as a normal date with the day always set to the first day of the month. And then at retrieval time you format the date, with something like a SimpleDateFormat, to only get the month and year and return it to your UI.