Java Date Format convertDateToString(Date date, String dateFormat)

Here you can find the source of convertDateToString(Date date, String dateFormat)

Description

convert Date To String

License

Apache License

Parameter

Parameter Description
date a parameter
dateFormat a parameter

Declaration

public static final String convertDateToString(Date date, String dateFormat) 

Method Source Code


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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**//  w  w w  .java  2s.c om
     * 
     * @param date
     * @param dateFormat
     * @return
     */
    public static final String convertDateToString(Date date, String dateFormat) {

        if (date == null) {
            return null;
        }

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        String dateStr = sdf.format(date);

        return dateStr;
    }
}

Related

  1. convertDateToString(Date date)
  2. convertDateToString(Date date)
  3. convertDateToString(Date date)
  4. convertDateToString(Date date, boolean millis)
  5. convertDateToString(Date date, int addHours)
  6. convertDateToString(Date date, String format)
  7. convertDateToString(Date date, String pattern)
  8. convertDateToString(Date date, String pattern)
  9. convertDateToString(Date date, String patternString, Locale locale)