Java Timestamp Create getTimeStamp()

Here you can find the source of getTimeStamp()

Description

get Time Stamp

License

Open Source License

Declaration

public static String getTimeStamp() 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String DEFAULT_DATE_FROMAT = "yyyyMMddHHmmss";
    public final static String DEFAULT_TIME_STAMP_FROMAT = "yyyy-MM-dd HH:mm:ss";

    public static String getTimeStamp() {
        return formatDateTime(DEFAULT_TIME_STAMP_FROMAT, new Date());
    }/*from w w  w  .j  ava 2 s  .c o  m*/

    public static String formatDateTime(java.util.Date date) {
        return formatDateTime(DEFAULT_DATE_FROMAT, date);
    }

    public static String formatDateTime(String pattern, java.util.Date date) {
        String strDate = null;
        String strFormat = pattern;
        SimpleDateFormat dateFormat = null;

        if (date == null)
            return "";

        dateFormat = new SimpleDateFormat(strFormat);
        strDate = dateFormat.format(date);

        return strDate;
    }
}

Related

  1. getTimestamp()
  2. getTimeStamp()
  3. getTimestamp()
  4. getTimestamp()
  5. getTimeStamp()
  6. getTimestamp()
  7. getTimeStamp()
  8. getTimestamp()
  9. getTimeStamp()