Android Date Format now(String dateFormat)

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

Description

Returns the current date in a given format.

Parameter

Parameter Description
dateFormat a date format (See examples)

Return

the current formatted date/time

Declaration

public static String now(String dateFormat) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**/*  www. ja v  a  2 s .c om*/
     * Returns the current date in a given format.
     * eg.=> CLDateUtil.now("dd MMMMM yyyy")
     * @param dateFormat a date format (See examples)
     * @return the current formatted date/time
     * @author Sean Zheng
     * @CreateDate 2013-5-13
     */
    public static String now(String dateFormat) {
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        long now = System.currentTimeMillis();
        return sdf.format(new Date(now));
    }
}

Related

  1. formatDateToString(Date timestamp)
  2. getStringByFormat(Date date, String format)
  3. getStringByFormat(Date date, String format)
  4. convertDateToString(Date date)
  5. formatDate(Date date)
  6. now(String dateFormat)
  7. getLongFriendlyDate(Date dt)
  8. getMainClockString(Date utcDate)
  9. currentDateToString(String format)