Java Now now(String dateFormat)

Here you can find the source of now(String dateFormat)

Description

Returns actual time and/or date in specified format.

License

Open Source License

Parameter

Parameter Description
dateFormat format of date to count

Return

actual time and/or date

Declaration

public static String now(String dateFormat) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    /**//from w w w  .j a  v  a 2 s  . com
     * Returns actual time and/or date in specified format.
     * @param dateFormat format of date to count
     * @return actual time and/or date
     */
    public static String now(String dateFormat) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        return sdf.format(cal.getTime());
    }
}

Related

  1. now()
  2. now()
  3. now()
  4. now()
  5. now(String dateFormat)
  6. now(String dateFormat)
  7. now(String dateFormat)
  8. now(String formatStr)
  9. now(String pattern)