Code example for SimpleDateFormat

Methods: parse

        // Create an instance of SimpleDateFormat with the specified 
        // format. 
        DateFormat sdf = new SimpleDateFormat("hh:mm:ss");
        try { 
            // The get the date object from the string just called the  
            // parse method and pass the time string to it. The method  
            // throws ParseException if the time string is in an  
            // invalid format. But remember as we don't pass the date  
            // information this date object will represent the 1st of 
            // january 1970. 
            Date date = sdf.parse(time);
            System.out.println("Date and Time: " + date);
        } catch (Exception e) {
Stop searching for code, let great code find you!  Add Codota to your java IDE