Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Convert String to Time (date)

$
0
0
Hi All,

I'm trying to convert a time input by the user in the format HH:mm into an actual Time so I can compare it to the current time.

I thought that one way to do this might be to convert it to a date so tried the following:

String time = "0000-00-00 " + hour + ":" + ":00";
            	DateFormat formatting ; 
            	 Date date ; 
            	  formatting = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            	  date = (Date)formatting.parse(time);




But I get the error "The method parse(String) is undefined for the type DateFormat"

Any ideas please?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>