I need help in converting a string to a date datatype in Java. I will have to receive a String key in by user and converts to the date datatype.
That means I'm setting my own date and converting to a date datatype.
I need help in converting a string to a date datatype in Java. I will have to receive a String key in by user and converts to the date datatype.
That means I'm setting my own date and converting to a date datatype.
First and foremost, define a SimpleDateFormat
format and create a date String
object that follows the format you predefined. Use SimpleDateFormat.parse(String)
to convert a String
to java.util.Date
object.
More details, please take a look at here.
For complete date and time patterns, please refer to this java.text.SimpleDateFormat JavaDoc.