Java yyyy formatDate(Date date, String pattern)

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

Description

format Date

License

Apache License

Declaration

public static String formatDate(Date date, String pattern) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

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

    public static String formatDate(Date date, String pattern) {
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.format(date);
    }//from   www .  java2s  .co m

    public static String formatDate(Date date) {
        return formatDate(date, DEFAULT_DATE_PATTERN);
    }

    /**
     * @param date long: 141536480014L
     * @return
     */
    public static String formatDate(long date) {
        return formatDate(new Date(date), DEFAULT_DATE_PATTERN);
    }
}

Related

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