Java Date Now getCurrentDate()

Here you can find the source of getCurrentDate()

Description

Returns the current date in the format that matches this#getDateFormat()

License

Open Source License

Return

The current date in the format that matches this#getDateFormat()

Declaration

public static String getCurrentDate() 

Method Source Code

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

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

public class Main {
    /**//from www . j a  v a 2s.  com
     * Returns the current date in the format that matches {@link this#getDateFormat()}
     *
     * @return The current date in the format that matches {@link this#getDateFormat()}
     */
    public static String getCurrentDate() {
        return new SimpleDateFormat(getDateFormat()).format(new Date(System.currentTimeMillis()));
    }

    /**
     * Returns the date format that should be used for dates
     *
     * @return The date format that should be used for dates
     */
    public static String getDateFormat() {
        return "yyyy-MM-dd HH:mm:ss.S";
    }
}

Related

  1. getCurrentDate()
  2. getCurrentDate()
  3. getCurrentDate()
  4. getCurrentDate()
  5. getCurrentDate()
  6. getCurrentDate()
  7. getCurrentDate()
  8. getCurrentDate()
  9. getCurrentDate()