Java yyyy format(Date date)

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

Description

format

License

Apache License

Declaration

public static String format(Date date) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String format(Date date) {
        if (date == null) {
            return "";
        }//from ww w .  j a  v  a 2  s  .co m
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        return df.format(date);
    }

    public static String format(Date date, String pattern) {
        if (date == null) {
            return "";
        }
        DateFormat df = new SimpleDateFormat(pattern);
        return df.format(date);
    }
}

Related

  1. format()
  2. format(Date aTs_Datetime)
  3. format(Date date)
  4. format(Date date)
  5. format(Date date)
  6. format(Date date)
  7. format(Date date)