Here you can find the source of formatTimestamp(Timestamp timestamp, int iType)
public static String formatTimestamp(Timestamp timestamp, int iType)
//package com.java2s; /**//from w ww . j a v a 2 s. c om * $RCSfile: DateUtil.java * $Revision: 1.0 * $Date: Jan 30, 2011 * * Copyright (C) 2010 SlFile, Inc. All rights reserved. * * This software is the proprietary information of SlFile, Inc. * Use is subject to license terms. */ import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatTimestamp(Timestamp timestamp, int iType) { String timeStr = ""; if (timestamp != null) { timeStr = getStrDate(new Long(timestamp.getTime()), iType); } return timeStr; } public static String getStrDate(java.lang.Long lDate, int iType) { Date date = new Date(lDate.longValue()); SimpleDateFormat simpleDateFormat = null; switch (iType) { case 0: simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); break; case 1: simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH"); break; case 2: simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); break; case 3: simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); break; } String strDate = simpleDateFormat.format(date); return (strDate); } }