Java Hour Format formatDate(java.util.Date date, String pattern)

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

Description

format Date

License

Open Source License

Declaration

public static String formatDate(java.util.Date date, String pattern) throws Throwable 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

public class Main {
    public static String formatDate(java.util.Date date, Boolean withTime, Boolean setTimeToNull) throws Throwable {
        // Format the new date in MF date format\
        if (withTime) {
            if (setTimeToNull) {
                return formatDate(date, "dd-MMM-yyyy 00:00:00");
            } else {
                return formatDate(date, "dd-MMM-yyyy HH:mm:ss");
            }// w  w  w  .  ja v  a 2  s  . c om
        } else {
            return formatDate(date, "dd-MMM-yyyy");
        }
    }

    public static String formatDate(java.util.Date date, String pattern) throws Throwable {
        // Format the new date in MF date format
        SimpleDateFormat formatterOut = new SimpleDateFormat(pattern);
        return formatterOut.format(date);
    }
}

Related

  1. formatDate(Date dateString)
  2. formatDate(Date src, String formatPattern)
  3. formatDate(final Date date, final String pattern)
  4. formatDate(final Date date, String pattern)
  5. formatDate(final String date)
  6. formatDate(java.util.Date dtFormat, String sFormatString)
  7. formatDate(Object obj, String format)
  8. formatDate(String date)
  9. formatDate(String date)