Java Date Now currentDate(String format)

Here you can find the source of currentDate(String format)

Description

current Date

License

Apache License

Declaration

public static String currentDate(String format) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {

    public static String currentDate(String format) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(isBlank(format) ? "yyyy-MM-dd HH:mm:ss" : format);
        return dateFormat.format(new Date());
    }//from w ww. j  a  v a 2 s . c  om

    public static String currentDate() {
        return currentDate("");
    }

    public static boolean isBlank(String str) {
        return (isEmpty(str) || (str.trim().length() == 0));
    }

    public static boolean isEmpty(String str) {
        return (str == null || str.length() == 0);
    }
}

Related

  1. currentDate()
  2. currentDate()
  3. currentDate()
  4. currentDate()
  5. currentDate(int dateStyle)
  6. currentDate(String format, Locale locale)
  7. currentDate(String format, String locale)
  8. currentDate2String()
  9. currentDate2String()