Java Date Now getCurrentDate()

Here you can find the source of getCurrentDate()

Description

get Current Date

License

Open Source License

Declaration

public static String getCurrentDate() 

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 SIMPLE_DATE_FROMAT = "yyyyMMdd";

    public static String getCurrentDate() {
        return formatDateTime(SIMPLE_DATE_FROMAT, new Date());
    }//from ww w . j  a  v  a2 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. getCurrentDataTimePrettyFilesystem()
  2. getCurrentDate()
  3. getCurrentDate()
  4. getCurrentDate()
  5. getCurrentDate()
  6. getCurrentDate()
  7. getCurrentDate()
  8. getCurrentDate()
  9. getCurrentDate()