Date/Time in java [duplicate]
Possible Duplicate:
how to convert java string to Date object
I have a form in which I insert a time in the form of : 10:19 as a String
. 开发者_如何学Python How can I convert this to the corresponding Time
object?
You need to parse the string into a Date object. You could use SimpleDateFormat.
Use SimpleDateFormat object.
Example:
DateFormat df = new SimpleDateFormat("HH:mm");
Date time;
try {
time = df.parse("10:19");
} catch (ParseException e) {
e.printStackTrace();
}
Use SimpleDateFormat that convert a string in a Calendar object or formats a Calendar object into a string
See the next links:
Java string to date conversion
http://www.roseindia.net/java/java-conversion/StringToDate.shtml
It was just Google.
精彩评论