Java Date Now getCurrentDate_YYYY_MM_DD()

Here you can find the source of getCurrentDate_YYYY_MM_DD()

Description

Here get the current date in format 'YYYY-MM-DD'

License

Open Source License

Return

Current date in format 'YYYY-MM-DD'

Declaration

public static String getCurrentDate_YYYY_MM_DD() 

Method Source Code


//package com.java2s;
import java.util.*;

public class Main {
    /**//from  ww w .  ja  v a  2 s  . c o m
     * Here get the current date in format 'YYYY-MM-DD'
     *
     * @return Current date in format 'YYYY-MM-DD'
     */
    public static String getCurrentDate_YYYY_MM_DD() {
        //    get current date in Format YYYY-MM-DD
        Calendar cal = Calendar.getInstance(TimeZone.getDefault());
        final String dateFormat = "yyyy-MM-dd";
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(dateFormat);
        sdf.setTimeZone(TimeZone.getDefault());
        return sdf.format(cal.getTime());
    }
}

Related

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