I am trying to use new SimpleDateFormat
to parse a string in the format dd-MM. Basically, I want to create a date object out of the string and persist in the database.
When I checked the database entry I see that it appends 1970 to the year column. I believe it is the default value of the year provided when it is empty. Is there a way to prevent the year value. I do not want to store information about the year.
My code -
String dateOfBirth = "14-Feb";
dbObject.save(new SimpleDateFormat("dd-MMM").parse(dateOfBirth));
For the sake of simplicity, assume dbObject.save()
the method expects a date object to be provided. I do not want to create a date of value - 14-Feb-1970, instead it should be just 14-Feb.