Java yyyy FormatDate(Date date, String sf)

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

Description

Format Date

License

Apache License

Declaration

public static String FormatDate(Date date, String sf) 

Method Source Code

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

import java.text.SimpleDateFormat;

public class Main {

    public static String FormatDate(Date date, String sf) {
        if (date == null)
            return "";
        SimpleDateFormat dateformat = new SimpleDateFormat(sf);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        if (date.getHours() == 0)
            return sdf.format(date);
        else//w  ww.  j  a va2  s.  c om
            return dateformat.format(date);
    }
}

Related

  1. formatDate(Date date, String outputPattern)
  2. formatDate(Date date, String pattern)
  3. formatDate(Date date, String pattern)
  4. formatDate(Date date, String pattern)
  5. formatDate(Date date, String pattern)
  6. formatDate(Date date, TimeZone timeZone)
  7. formatDate(Date inputDate, String formatPattern)
  8. formatDate(Date unformattedDate, String format)
  9. formatDate(DateTime aDateTime)