Java Date Now getNowDate()

Here you can find the source of getNowDate()

Description

return current date value in format: yyyy-MM-dd

License

Apache License

Return

String value

Declaration

public static String getNowDate() 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**//from ww  w . ja  v  a 2s. co m
     * return current date value in format: yyyy-MM-dd
     *
     * @return String value
     */
    public static String getNowDate() {
        return dateToStringWithPattern(new Date(), "yyyy-MM-dd");
    }

    /**
     * return time value of specified date
     *
     * @param date    the specified date to convert
     * @param pattern time format
     * @return String value
     */
    public static String dateToStringWithPattern(Date date, String pattern) {
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
            return simpleDateFormat.format(date);
        } catch (Exception e) {
            return "";
        }
    }
}

Related

  1. getCurrentYearBegDate(Date date)
  2. getCurrentYMDDate()
  3. getCurrentZeroTime()
  4. getDayToMonthEnd(boolean iscurrentdate)
  5. getNowDate()
  6. getNowDate()
  7. getNowDate()
  8. getNowDate()
  9. getNowDate()