Here you can find the source of getHoraHHMM(Timestamp dataHoraRef)
public static String getHoraHHMM(Timestamp dataHoraRef)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.util.GregorianCalendar; public class Main { public static String getHoraHHMM(Timestamp dataHoraRef) { // cria um StringBuilder StringBuilder sb = new StringBuilder(); // cria um GregorianCalendar que vai conter a hora atual GregorianCalendar d = new GregorianCalendar(); d.setTime(dataHoraRef);/* w ww.j a v a2 s. c o m*/ String aux = "" + d.get(GregorianCalendar.HOUR_OF_DAY); if (aux.length() < 2) aux = "0" + aux; sb.append(aux); aux = "" + d.get(GregorianCalendar.MINUTE); if (aux.length() < 2) aux = "0" + aux; sb.append(":"); sb.append(aux); return sb.toString(); } }