Here you can find the source of ConvertTimestamp(long sec)
public static Timestamp ConvertTimestamp(long sec)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static Timestamp ConvertTimestamp(long sec) { long unixSeconds = sec / 1000; Date date = new Date(unixSeconds * 1000L); // *1000 is to convert seconds to milliseconds SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // the format of your date sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); // give a timezone reference for formating (see comment at the bottom String dt = sdf.format(date); return Timestamp.valueOf(dt); }/*from w w w . j a v a 2 s . co m*/ }