Here you can find the source of Timestamp2HHMMSS(java.sql.Timestamp ts, int iStyle)
public static String Timestamp2HHMMSS(java.sql.Timestamp ts, int iStyle)
//package com.java2s; public class Main { public static String Timestamp2HHMMSS(java.sql.Timestamp ts, int iStyle) { if (ts == null) { return ""; }// ww w . ja va 2 s.c o m java.util.Calendar calendar = java.util.Calendar.getInstance(); calendar.setTime(new java.util.Date(ts.getTime())); String strTemp; if (iStyle == 0) { strTemp = Integer.toString(calendar.get(calendar.HOUR_OF_DAY)); } else { strTemp = Integer.toString(calendar.get(calendar.HOUR_OF_DAY)); } if (strTemp.length() < 2) { strTemp = "0" + strTemp; } if (calendar.get(calendar.MINUTE) < 10) { strTemp += ":0" + calendar.get(calendar.MINUTE); } else { strTemp += ":" + calendar.get(calendar.MINUTE); } if (calendar.get(calendar.SECOND) < 10) { strTemp += ":0" + calendar.get(calendar.SECOND); } else { strTemp += ":" + calendar.get(calendar.SECOND); } if (iStyle != 0) { if (calendar.get(calendar.AM_PM) == calendar.AM) { strTemp += " AM"; } else { strTemp += " PM"; } } return strTemp; } }