Java Time Now getNowDateTime()

Here you can find the source of getNowDateTime()

Description

get Now Date Time

License

Open Source License

Declaration

public static String getNowDateTime() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final SimpleDateFormat defaultFormater = new SimpleDateFormat("yyyyMMdd");
    private static final SimpleDateFormat customizedFormater = new SimpleDateFormat("yyyyMMdd");

    public static String getNowDateTime() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        return dateFormat.format(new Date());
    }/*from  w  ww  .  j a va2  s  .c om*/

    public static String format(Date date, String pattern) {
        synchronized (customizedFormater) {
            if (null != pattern && !"".equals(pattern.trim())) {
                customizedFormater.applyPattern(pattern);
            } else {
                throw new IllegalArgumentException("pattern can not be empty");
            }
            return customizedFormater.format(date);
        }
    }

    public static String format(Date date) {
        synchronized (defaultFormater) {
            return defaultFormater.format(date);
        }
    }
}

Related

  1. getNow(boolean ifdatetime)
  2. getNow(final String format)
  3. getNow(String format)
  4. getNowAsNICSDate()
  5. getNowAsString()
  6. getNowDateTime()
  7. getNowDateTime()
  8. getNowDateTime()
  9. getNowDateTime(String strScheme)