parse string to date and time but not getting appropriate parsing
<p>i am attaching the code. In this code i am taking a string which is a date from a flat text file. It consist of AM/PM(12 Hour Format). When i am parsing it, it is not parsing well not parsing in 24 hour format. I want the time difference b/w the current time and the string from file. And because of AM/PM its not converting in 24 hour format. So its showing same time difference whether it is PM or AM. So tell me any fruitful suggestion if you have. I ll be really thankful to you guys.</p>

<p>public class Casting {</p>

<pre><code>/**
 * @param args
 */
    static FileReader fw;
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        try{
            fw = new FileReader("E://796F_log.txt");
            BufferedReader pw =new BufferedReader(fw);
            String last_Line_From_File="" ; 

            for (String message  = pw.readLine(); message != null ; message = pw.readLine()) {
                    last_Line_From_File = message;
            }

            String[] array_Of_Data = last_Line_From_File.split("\\s") ;
            String time = array_Of_Data[0]+" "+array_Of_Data[1]+" "+array_Of_Data[2] ;

            System.out.println(time);
            DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a");
            Calendar cal = Calendar.getInstance();
            String current_time = dateFormat.format(cal.getTime());

            Date d1 = dateFormat.parse(time);
            Date d2 = dateFormat.parse(current_time);



            long total_time = d2.getTime()-d1.getTime();
            total_time /= 1000 ;

            System.out.println("current time "+d2.getHours()+":"+d2.getMinutes()+":"+d2.getSeconds()+"\n"+d1.getHours()+":"+d1.getMinutes()+":"+d1.getSeconds());
            if(total_time &lt;= 500)
            {
                System.out.println("working "+total_time);
            }
            else
                System.out.println("nt working   "+total_time);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.out.println("did the smart thing or dumb thing");
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally
        {
            try {
                fw.close();

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                System.out.println("we did attempt closing");

            }

        }
    }
</code></pre>

<p>}</p>
