Java Utililty Methods Timestamp from

List of utility methods to do Timestamp from

Description

The list of methods to do Timestamp from are organized into topic(s).

Method

TimestampconvertDateStringToTimestamp(String dateString, String format)
convert Date String To Timestamp
String day = "";
String month = "";
String year = "";
String hour = "";
String minute = "";
String second = "";
StringTokenizer st;
Timestamp dateTime = null;
...
TimestampconvertDateToTimestamp(Date date)
convert Date To Timestamp
Timestamp ts = new Timestamp(date.getTime());
return ts;
TimestampconvertDateToTimestamp(java.util.Date date)
Return a timestamp from an util date
Timestamp ts = null;
try {
    ts = new Timestamp(date.getTime());
} catch (Exception e) {
return ts;
TimestampconvertLongToTimestamp(Long millSec)
convert Long To Timestamp
return new Timestamp(millSec);
java.sql.TimestampconvertSQLTimestamp(String s, String formatIn, String formatOut)
returns a SQL Timestamp given a formatted string
String s2 = convertStringDate(s, formatIn, formatOut);
return java.sql.Timestamp.valueOf(s2 + ".0");
TimestampconvertString2TimeStamp(String dateString)
convert String Time Stamp
return new Timestamp(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(dateString).getTime());
java.sql.TimestampconvertString2Timestamp(String value)
convert String Timestamp
java.sql.Timestamp out = null;
if (value == null) {
    out = new java.sql.Timestamp(0);
} else {
    try {
        String v = value.toString().trim();
        if (v.length() == 8) { 
            String yearString = v.substring(0, 4);
...
TimestampconvertStringDateToTimestamp(String sDate, String dateformat)
convert String Date To Timestamp
SimpleDateFormat dateFormat;
Date date;
Timestamp timestamp = null;
try {
    dateFormat = new SimpleDateFormat(dateformat);
    date = dateFormat.parse(sDate);
    timestamp = new Timestamp(date.getTime());
} catch (ParseException e) {
...
TimestampconvertStringToTimeStamp(String date)
convert String To Time Stamp
if (null == date || date.isEmpty()) {
    return null;
Timestamp ts = null;
if (date.indexOf("/") != -1) {
    date = date.replace("/", "-");
try {
...
TimestampconvertStringToTimestamp(String str)
convert String To Timestamp
Timestamp ts = new Timestamp(System.currentTimeMillis());
try {
    ts = Timestamp.valueOf(str);
} catch (Exception ex) {
    throw new Exception(ex.getMessage() + str);
return ts;