Java Date Now getCurrentDate_String()

Here you can find the source of getCurrentDate_String()

Description

get Current Dat String

License

Open Source License

Declaration

public static String getCurrentDate_String() 

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 final String DF_YMD = "yyyy-MM-dd";

    public static String getCurrentDate_String() {
        return dateToString(now(), DF_YMD);
    }/*from  w ww .ja  v  a 2  s.c  om*/

    public static String dateToString(Date date, String format) {
        if (date == null) {
            return "";
        }
        synchronized (date) {
            SimpleDateFormat df = new SimpleDateFormat(format);
            return df.format(date);
        }
    }

    public static String dateToString(Date date) {
        return dateToString(date, DF_YMD);
    }

    public static Date now() {
        return new Date();
    }
}

Related

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