Is there a straightforward way of converting a Java SQL Date from format yyyy-MM-dd to dd MMMM yyyy format?
I could convert the date to a string and then manipulate it but I’d rather leave it as a Java SQL Date. at the time I need to do this, the data has already been read from the MySQL database so I cant do the change there.
Object such as
java.sql.Dateandjava.util.Date(of whichjava.sql.Dateis a subclass) don’t have a format of themselves. You use ajava.text.DateFormatobject to display these objects in a specific format, and it’s theDateFormat(not theDateitself) that determines the format.For example:
Note: When you print a
Dateobject without using aDateFormatobject, like this:then it will be formatted using some default format. That default format is however not a property of the
Dateobject that you can change.