Android Date Format date(Date date)

Here you can find the source of date(Date date)

Description

date

Declaration

public static String date(Date date) 

Method Source Code

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

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

public class Main {
    public static String date(Date date) {
        return format(date, "yyyy-MM-dd");
    }//from ww  w .jav  a 2  s .c o m

    public static String format(Date date, String format) {
        if (date == null || format == null) {
            return "";
        }

        DateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }

    public static String format(Date date) {
        return format(date, "yyyy-MM-dd HH:mm");
    }

    public static String format(Date date, boolean isDateOnly) {
        if (isDateOnly) {
            return date(date);
        } else {
            return format(date);
        }
    }
}

Related

  1. FormatToString(Date date, String format)
  2. FormatToString(String date, String format)
  3. ParseDateToString(Date date)
  4. ParseDateToString(Date date, String format)
  5. format(Date date)
  6. format(Date date, String format)
  7. format(Date date, boolean isDateOnly)
  8. formatDA(Date d)