i.e. 00:00:00 particularly in this format.
How do I go about in validating this string to ensure it is valid? Any idea?
You can split this string by : and work on each part. Surely index 0 is hour and must be between 0 and 23 Index 1 is minute and must be between 0 and 59 Index 2 is second and validation is like minute.
I would just parse it with Java built in date formatter. On success you get handy Date/TimeOfDay object you can proceed working with. Exception indicates that your input string has wrong format. Using regexp is a nice option, just like @shubhamsomu suggested, but I'm sure that couple lines down you'll still need to convert it into Java object to work with it. So you'll end up doing same thing twice
Обсуждают сегодня