title: How to display only time part from date time combination in java
body: <p>I am new to Java. I am retrieving my first column from database in a String Array which represents data as:</p>
  
  <pre><code>2014-09-01 10:00:00.000
  </code></pre>
  
  <p>Now I want to display only time as:</p>
  
  <pre><code>10:00:00
  </code></pre>
  
  <p>How to do it?
  My code to retrieve my Column is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public String[] getChartTime() throws SQLException {
    List &lt; String &gt; timeStr = new ArrayList &lt; String &gt; ();
    String atime[] = null;
    getConnection();
    try {
      con = getConnection();
  
  
      String sql = "exec vcs_gauge @gauge_name=?,@first_rec_time=?,@last_rec_time=?";
      DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      System.out.println("date is " + df.format(currentDate));
      clstmt = con.prepareCall(sql);
      clstmt.setString(1, "vs3_bag");
      clstmt.setString(2, "2014-09-01 10:00:00");
      clstmt.setString(3, "2014-09-01 11:00:00");
      clstmt.execute();
      rs = clstmt.getResultSet();
  
      while (rs.next()) {
        // Just get the value of the column, and add it to the list
        timeStr.add(rs.getString(1));
  
      }
  
    } catch (Exception e) {
      System.out.println("\nException in  Bean in getDbTable(String code):" + e);
    } finally {
      closeConnection();
    }
    // I would return the list here, but let's convert it to an array
    atime = timeStr.toArray(new String[timeStr.size()]);
    for (String s: atime) {
      System.out.println(s);
    }
  
    return atime;
  
  
  }</code></pre>
  </div>
  </div>
  </p>