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

StringgetTimestampDateDotTime()
Return a timestamp in the format of yyyyMMdd.HHmmss.
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd.HHmmss");
return sdf.format(new Date());
TimestampgetTimestampDiff(int n)
get Timestamp Diff
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = new Date();
Date dayDiff = new Date(d.getTime() + n * 24 * 3600 * 1000L);
String time = df.format(dayDiff);
return Timestamp.valueOf(time);
FilegetTimestampedPNGFile(File saveDir)
get Timestamped PNG File
String s = DATE_FORMAT.format(new Date()).toString();
int i = 1;
while (true) {
    File file1 = new File(saveDir, s + (i == 1 ? "" : "_" + i) + ".png");
    if (!file1.exists()) {
        return file1;
    ++i;
...
StringgetTimestampedVideoFileName()
get Timestamped Video File Name
LocalDateTime dateTime = LocalDateTime.now();
return Timestamp.valueOf(dateTime).toString().split(" ")[1];
DateFormatgetTimestampFormat()
get Timestamp Format
return new SimpleDateFormat(timestampFormat);
SimpleDateFormatgetTimestampFormat()
get Timestamp Format
String defaultTimestampFormat = "MM/dd/yyyy HH:mm:ss";
return new SimpleDateFormat(defaultTimestampFormat);
SimpleDateFormatgetTimestampFormat()
Get a date formatter for timestamp
return new SimpleDateFormat(TIMESTAMP_FORMAT_S);
SimpleDateFormatgetTimestampFormatter()
Returns a formatter capable of producing and parsing timestamps.
return new SimpleDateFormat("yyyyMMddHHmmssz");
TimestampgetTimestampFromDate(Date d)
Method getTimestampFromDate.
Calendar caldate = Calendar.getInstance();
caldate.setTime(d);
Timestamp t = new Timestamp(caldate.getTimeInMillis());
t.setNanos(0);
t.setTime(caldate.getTimeInMillis());
return t;
longgetTimestampFromDate(String d)
get Timestamp From Date
try {
    return DATE_NAME_FORMAT.parse(d).getTime();
} catch (ParseException e) {
    System.err.println(d + " getTimestampFromDate " + e.getMessage());
return 0;