Here you can find the source of convertTimestampToString(Timestamp dateTime, String dateFormat)
Parameter | Description |
---|---|
dateTime | a parameter |
public static String convertTimestampToString(Timestamp dateTime, String dateFormat)
//package com.java2s; //License from project: LGPL import java.sql.Timestamp; public class Main { /**/* w w w. ja va2 s. c om*/ * convert timestamp to sql string date format * @param dateTime * @param withTime * @return String */ public static String convertTimestampToString(Timestamp dateTime, boolean withTime) { String s = ""; java.text.SimpleDateFormat ft = null; if (withTime) { ft = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } else { ft = new java.text.SimpleDateFormat("yyyy-MM-dd"); } s = ft.format(dateTime); return s; } /** * convert timestamp to format yyyyMMdd * @param dateTime * @return String */ public static String convertTimestampToString(Timestamp dateTime, String dateFormat) { String s = ""; java.text.SimpleDateFormat ft = null; ft = new java.text.SimpleDateFormat(dateFormat); s = ft.format(dateTime); return s; } }