Java Now nowIdentity()

Here you can find the source of nowIdentity()

Description

Returns the current identity like '20090831182858668'

License

Open Source License

Declaration

public static String nowIdentity() 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**/* w w w  .ja va2s. c  om*/
     * Returns the current identity like '20090831182858668'
     *
     * @return
     */
    public static String nowIdentity() {
        return getFormat(now(), "yyyyMMddHHmmssSSS");
    }

    public static String getFormat(java.util.Date date, String parseFormat) {
        if (null == date) {
            return null;
        }
        if (null == parseFormat || "".equalsIgnoreCase(parseFormat)) {
            return date.toString();
        }
        return new SimpleDateFormat(parseFormat).format(date);
    }

    /**
     * Returns the current datetime.
     * 
     * @return the current datetime.
     */
    public static Date now() {
        return new Date(System.currentTimeMillis());
    }
}

Related

  1. nowDT()
  2. nowDT()
  3. nowFile()
  4. nowFormat(String format)
  5. nowFormat(String format)
  6. nowInBasicFormat()
  7. nowStr()
  8. nowString(String pattern)
  9. nowString(String pattern)