Java Utililty Methods Millisecond Format

List of utility methods to do Millisecond Format

Description

The list of methods to do Millisecond Format are organized into topic(s).

Method

StringreverseFormattedDateWithMilliseconds()
reverse Formatted Date With Milliseconds
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String formatted = format.format(cal.getTime());
assert (formatted != null);
return formatted;
longstringToTimestampInMilliseconds(String s, DateFormat formatter)
Convert a date time string (e.g., "2011-06-07 19:12:18") to a timestamp in milliseconds (i.e., the number of milliseconds since January 1, 1970, 00:00:00 GMT.
Date d = stringToDate(s, formatter);
return d == null ? 0 : d.getTime();
longstrToDateMillisTimestamp(String dateStr, String formatStr)
str To Date Millis Timestamp
Date date = strToDate(dateStr, formatStr);
return date != null ? date.getTime() : 0;
StringtimeFormat(final long milliseconds)
Converts into seconds and returns a string in the format . .
double seconds = milliseconds / 1000.0d;
final NumberFormat fmt = new DecimalFormat("#0.000");
return fmt.format(seconds);
StringtimeMillisToString(long timeMillis, String dateFormat)
time Millis To String
if ("".equals(dateFormat) || dateFormat == null) {
    return null;
try {
    return new SimpleDateFormat(dateFormat).format(new Date(timeMillis));
} catch (Exception e) {
    return null;