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

TimestampconvertToTimestamp(Date aJavaDate)
convert To Timestamp
Timestamp retVal = null;
if (aJavaDate != null) {
    retVal = new Timestamp(aJavaDate.getTime());
return retVal;
TimestampconvertToTimestamp(java.util.Date date)
Converts java.util.Date to java.sql.Timestamp
if (date == null) {
    throw new IllegalArgumentException("date msut not be null");
Timestamp timestamp = new Timestamp(date.getTime());
return timestamp;
TimestampconvertToTimestamp(String dateData)
convert To Timestamp
try {
    if (dateData == null)
        return null;
    if (dateData.trim().equals(""))
        return null;
    int dateObjLength = dateData.length();
    String yearString = "2002";
    String monthString = "01";
...
TimestampconvertToTimestamp(String dateString, String pattern)
convert To Timestamp
Date date = convertToDate(dateString, pattern);
if (date != null) {
    return new Timestamp(date.getTime());
} else {
    return null;
TimestampconvertToTimestamp(String s)
convert To Timestamp
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
Timestamp timestamp = null;
try {
    timestamp = new Timestamp(dateFormat.parse(s).getTime());
} catch (ParseException e) {
    e.printStackTrace();
return timestamp;
...
StringconvertToTimeStamp(Timestamp timestamp, String format, TimeZone timeZone)
This method converts a given time stamp in a specified date format and as per specified time zone
String strTimeStamp = "";
if (timestamp == null)
    return strTimeStamp;
final SimpleDateFormat dateFormat = new SimpleDateFormat(format);
dateFormat.setTimeZone(timeZone);
strTimeStamp = dateFormat.format(timestamp);
return strTimeStamp;
TimestampconvertToTimestampDate(Date date)
convert To Timestamp Date
return new Timestamp(date.getTime());
TimestampconvertToTimestampHMS(String dateData)
convert To Timestamp HMS
if (dateData == null)
    return null;
if (dateData.trim().equals(""))
    return null;
String yearString = dateData.substring(0, 4);
String monthString = dateData.substring(4, 6);
String dayString = dateData.substring(6, 8);
String hourString = dateData.substring(8, 10);
...
TimestampgetFirstTimeOfDay(Calendar calendar)
get First Time Of Day
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
return new Timestamp(calendar.getTimeInMillis());
java.sql.TimestamptimestampFromCalendar(Calendar calendar)
Answer a Timestamp from a Calendar.
return timestampFromLong(calendar.getTimeInMillis());