Android Date Format format(Date date, String format)

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

Description

format

Declaration

public static String format(Date date, String format) 

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 v  a 2 s .co  m

        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. FormatToString(String date, String format)
  2. ParseDateToString(Date date)
  3. ParseDateToString(Date date, String format)
  4. date(Date date)
  5. format(Date date)
  6. format(Date date, boolean isDateOnly)
  7. formatDA(Date d)
  8. formatDT(Date d)
  9. formatDate(Context context, Calendar date, FileTimeDisplay fileTimeDisplay)