Java Timestamp Format formatTimestamp(Date date)

Here you can find the source of formatTimestamp(Date date)

Description

Formats a date object based on the format setting in compass.timestampFormat

License

LGPL

Declaration

public static String formatTimestamp(Date date) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**//from  ww  w  .  j ava2 s .  c o  m
     * Formats a date object based on the format setting
     * in compass.timestampFormat
     * @params date date object to format
     */
    public static String formatTimestamp(Date date) {
        if (date == null) {
            return "";
        }
        return getTimestampFormat().format(date);
    }

    private static SimpleDateFormat getTimestampFormat() {
        String defaultTimestampFormat = "MM/dd/yyyy HH:mm:ss";
        return new SimpleDateFormat(defaultTimestampFormat);
    }
}

Related

  1. formatTime(Date aTs_Datetime)
  2. formatTime(Date date)
  3. formatTime(Timestamp time, boolean onlyTime)
  4. formatTime(Timestamp ts, Locale locale)
  5. formatTimeFromTimestamp(long ts, String fmt)
  6. formatTimestamp(Date timestamp)
  7. formatTimestamp(Date timestamp)
  8. formatTimestamp(Date timestamp)
  9. formatTimestamp(final Date date)