List of utility methods to do Timestamp Create
String | getTimestampDateDotTime() Return a timestamp in the format of yyyyMMdd.HHmmss. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd.HHmmss"); return sdf.format(new Date()); |
Timestamp | getTimestampDiff(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); |
File | getTimestampedPNGFile(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; ... |
String | getTimestampedVideoFileName() get Timestamped Video File Name LocalDateTime dateTime = LocalDateTime.now(); return Timestamp.valueOf(dateTime).toString().split(" ")[1]; |
DateFormat | getTimestampFormat() get Timestamp Format return new SimpleDateFormat(timestampFormat); |
SimpleDateFormat | getTimestampFormat() get Timestamp Format String defaultTimestampFormat = "MM/dd/yyyy HH:mm:ss"; return new SimpleDateFormat(defaultTimestampFormat); |
SimpleDateFormat | getTimestampFormat() Get a date formatter for timestamp return new SimpleDateFormat(TIMESTAMP_FORMAT_S); |
SimpleDateFormat | getTimestampFormatter() Returns a formatter capable of producing and parsing timestamps. return new SimpleDateFormat("yyyyMMddHHmmssz"); |
Timestamp | getTimestampFromDate(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; |
long | getTimestampFromDate(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; |