Here you can find the source of convertToTimeStamp(Timestamp timestamp, String format, TimeZone timeZone)
Parameter | Description |
---|---|
timestamp | input time stamp |
format | input date format as per which output is required |
timeZone | input time zone in which time stamp needs to be converted |
public static String convertToTimeStamp(Timestamp timestamp, String format, TimeZone timeZone)
//package com.java2s; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.TimeZone; public class Main { /**//from w w w . j a va2s .com * This method converts a given time stamp in a specified date format and as per specified time zone * @param timestamp input time stamp * @param format input date format as per which output is required * @param timeZone input time zone in which time stamp needs to be converted * @return */ public static String convertToTimeStamp(Timestamp timestamp, String format, TimeZone timeZone) { String strTimeStamp = ""; if (timestamp == null) return strTimeStamp; final SimpleDateFormat dateFormat = new SimpleDateFormat(format); dateFormat.setTimeZone(timeZone); strTimeStamp = dateFormat.format(timestamp); return strTimeStamp; } }