title: converting time from hh:mm:ss to hh:mm in java
body: <p>I want to convert time to hh:mm from hh:mm:ss
  it comes from database (my sql) in the form of hh:mm:ss.
  I tried the following code but i didn't get what i want.</p>
  
  <pre><code> try {
  
          s= HibernateUtil.currentSession();
          tx=s.beginTransaction();
          Query query = s.createQuery("select from Dailytimesheet dailytimesheet where dailytimesheet.IdDailyTimeSheet=6083 " );         
  
               for(Iterator it=query.iterate();it.hasNext();)
               {                                                                           
                                 if(it.hasNext())
                                 {
  
                                     Dailytimesheet object=(Dailytimesheet)it.next();
                                     String dt=object.getTimeFrom().toString();
                                     SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");  
                                     long ms=0;
                              try {
                                  ms = sdf.parse(dt).getTime();
                                  } 
                              catch (ParseException e) {e.printStackTrace();}
                                  Time ts = new Time(ms);
  
  
           out.println("&lt;h2&gt;"+ts+"&lt;/h2&gt;");                       
  </code></pre>
  
  <p>thanks for your help.</p>