Java Date Now getCurrentDate(String pattern)

Here you can find the source of getCurrentDate(String pattern)

Description

get Current Date

License

Open Source License

Declaration

public static String getCurrentDate(String pattern) 

Method Source Code


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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static String getCurrentDate(String pattern) {
        SimpleDateFormat datePattern = null;
        if (null == pattern || "".equals(pattern)) {
            datePattern = new SimpleDateFormat("yyyyMMdd");
        } else {/* w  ww .ja va  2  s .  co m*/
            datePattern = new SimpleDateFormat(pattern);
        }
        return datePattern.format(new Date());
    }
}

Related

  1. getCurrentDate(String format)
  2. getCurrentDate(String format)
  3. getCurrentDate(String format)
  4. getCurrentDate(String format)
  5. getCurrentDate(String formatStr)
  6. getCurrentDate(String pattern)
  7. getCurrentDate(String pattern)
  8. getCurrentDate(String pattern, Locale locale)
  9. getCurrentDate2(String format)