Java Utililty Methods Timestamp Create

List of utility methods to do Timestamp Create

Description

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

Method

StringgetTimestamp(Date date, String timestampPattern)
get Timestamp
if (date != null && timestampPattern != null) {
    SimpleDateFormat formatter = new SimpleDateFormat(timestampPattern);
    return formatter.format(date);
return date != null ? date.toString() : null;
StringgetTimestamp(Date time)
Converts a time to timestamp format.
return getTimestampFormatter().format(time == null ? new Date() : time);
longgetTimestamp(final File file)
get Timestamp
final long modified = file.lastModified();
return Long.parseLong(timestamp(modified));
TimestampgetTimestamp(final LocalDate date)
get Timestamp
return date != null ? Timestamp.valueOf(date.atStartOfDay()) : null;
TimestampgetTimestamp(final Map map, final Object key)
get Timestamp
return getTimestamp(map, key, null);
StringgetTimestamp(int offset)
get Timestamp
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, offset);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
return formatter.format(cal.getTime());
TimestampgetTimestamp(int year, int month, int day, int hour, int min, int second)
get Timestamp
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, day, hour, min, second);
return new Timestamp(calendar.getTimeInMillis());
java.sql.TimestampgetTimestamp(java.util.Date utilDate)
converts a java.util.Date to java.sql.Timestamp
return new java.sql.Timestamp(utilDate.getTime());
java.sql.TimestampgetTimestamp(long time)
Convert a millisecond value to a Timestamp.
return new java.sql.Timestamp(time);
TimestampgetTimestamp(Object o)
get Timestamp
Timestamp sh = null;
if (null == o)
    return sh;
if (o instanceof Date) {
    sh = (Timestamp) o;
return sh;