How do I convert string of time to time object?

Share:

You want to convert a string reprsenting a time into a time object in Java. As we know that Java is representing a time information in a class java.util.Date, this class keep information about date and time.

Now if you have a string of time you can use a SimpleDateFormat object to parse the string date and return a date object. The pattern of the string should be passed to the simple date format constructor. In the example below the string is formatted as hh:mm:ss (hour:minutes:second).

Share: