Why does java not convert my time correctly?
<p>I have the following method to convert a String to Date object</p>

<pre><code>public Date convertTime(String time) {

    SimpleDateFormat parser = new SimpleDateFormat("d/M/y HH:mm:ss.S");
    try {
        return parser.parse(time);
    }
    catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }


}
</code></pre>

<p>I have the following method to convert it back</p>

<pre><code>public String dateToTimeMillis(Date date) {

    //StringBuffer formatted = new StringBuffer();
    SimpleDateFormat parser = new SimpleDateFormat("HH:mm:ss.S");
    try {
        String formatted = parser.format(date);
        return formatted;
    }
    catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }


}
</code></pre>

<p>The following test code</p>

<pre><code>    TraderLib lib = new TraderLib();
    Date d1 = lib.convertTime("01/11/2011 10:41:09.045");
    System.out.println(lib.dateToTimeMillis(d1));
</code></pre>

<p>returns 10:41:09.45</p>

<p>How do I preserve the 0?</p>
