Java yyyy formatDate(Date date, String format)

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

Description

format Date

License

Open Source License

Declaration

public static String formatDate(Date date, String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";

    public static String formatDate(Date date) {
        if (date == null) {
            return "";
        }/*from   www  . j  a  va  2s.c om*/
        return new SimpleDateFormat(DEFAULT_DATE_FORMAT).format(date);
    }

    public static String formatDate(Date date, String format) {
        if (date == null) {
            return null;
        }
        return new SimpleDateFormat(format).format(date);
    }
}

Related

  1. formatAsNumber(Date date)
  2. formatBySlashForm(Date aDate)
  3. formatDate(Calendar cal, String pattern)
  4. formatDate(Calendar calendar, String format)
  5. formatDate(Date date, String datePattern)
  6. formatDate(Date date, String format)
  7. formatDate(Date date, String outputPattern)
  8. formatDate(Date date, String pattern)
  9. formatDate(Date date, String pattern)