Java Date Now getCurrentDate(String format)

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

Description

get Current Date

License

Open Source License

Declaration

public static String getCurrentDate(String format) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String getCurrentDate(String format) {
        return new SimpleDateFormat(format).format(new Date());
    }//w  ww.  j  av  a2 s.  c o  m

    public static Date getCurrentDate() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String s = sdf.format(new Date());
        Date date = null;
        try {
            date = sdf.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}

Related

  1. getCurrentDate(final String FORMAT)
  2. getCurrentDate(String format)
  3. getCurrentDate(String format)
  4. getCurrentDate(String format)
  5. getCurrentDate(String format)
  6. getCurrentDate(String format)
  7. getCurrentDate(String format)
  8. getCurrentDate(String formatStr)
  9. getCurrentDate(String pattern)