Android Date Format format(Date date, boolean isDateOnly)

Here you can find the source of format(Date date, boolean isDateOnly)

Description

format

Declaration

public static String format(Date date, boolean isDateOnly) 

Method Source Code

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

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

public class Main {

    public static String format(Date date, String format) {
        if (date == null || format == null) {
            return "";
        }/*w w  w  .  j a  va 2 s.com*/

        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);
        }
    }

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

Related

  1. ParseDateToString(Date date)
  2. ParseDateToString(Date date, String format)
  3. date(Date date)
  4. format(Date date)
  5. format(Date date, String format)
  6. formatDA(Date d)
  7. formatDT(Date d)
  8. formatDate(Context context, Calendar date, FileTimeDisplay fileTimeDisplay)
  9. formatDate(Context context, long millis, FileTimeDisplay fileTimeDisplay)