Java Hour Format formatDate(Date date, String patter)

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

Description

format Date

License

Apache License

Parameter

Parameter Description

Return

String

Declaration

public static String formatDate(Date date, String patter) 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String formatDate(Date date, String patter) {
        try {//from  ww w.java2s  . com
            SimpleDateFormat sdf = new SimpleDateFormat(patter);
            return sdf.format(date);
        } catch (RuntimeException e) {
            return "";
        }
    }

    public static String formatDate(Date date) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return sdf.format(date);
        } catch (RuntimeException e) {
            return "";
        }
    }
}

Related

  1. formatDate(Date date, String format)
  2. formatDate(Date date, String format)
  3. formatDate(Date date, String format)
  4. formatDate(Date date, String format)
  5. formatDate(Date date, String format, Locale locale)
  6. formatDate(Date date, String pattern)
  7. formatDate(Date date, String pattern)
  8. formatDate(Date date, String timeFormat, String timeZone)
  9. formatDate(Date date, StringBuffer buffer)