Java Date Now currentDate(int dateStyle)

Here you can find the source of currentDate(int dateStyle)

Description

Current date as formatted string representation.

License

Open Source License

Parameter

Parameter Description
dateStyle one of DateFormat.SHORT, MEDIUM, LONG, FULL

Return

the formatted date string.

Declaration

public static String currentDate(int dateStyle) 

Method Source Code


//package com.java2s;
import java.text.DateFormat;
import java.util.Date;

public class Main {
    /**//from www  .j av  a 2  s. c o  m
     * Current date as formatted string representation.
     * 
     * @param dateStyle
     *            one of DateFormat.SHORT, MEDIUM, LONG, FULL
     * @return the formatted date string.
     */
    public static String currentDate(int dateStyle) {
        DateFormat df = DateFormat.getDateInstance(dateStyle);
        return df.format(new Date());
    }
}

Related

  1. currentDate()
  2. currentDate()
  3. currentDate()
  4. currentDate()
  5. currentDate()
  6. currentDate(String format)
  7. currentDate(String format, Locale locale)
  8. currentDate(String format, String locale)
  9. currentDate2String()