Java Date to String ConvertToString(Date date, String format)

Here you can find the source of ConvertToString(Date date, String format)

Description

Converts a date object to a string using the specified format.

License

Open Source License

Parameter

Parameter Description
date Date object
format String format

Return

Formatted date/time

Declaration

public static String ConvertToString(Date date, String format) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    /** Converts a date object to a string using the specified format.
     */*w  w  w .  j a va 2  s.  c o m*/
     * @param date Date object
     * @param format String format
     * @return Formatted date/time
     */
    public static String ConvertToString(Date date, String format) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        return dateFormat.format(date);
    }
}

Related

  1. convertDateToString(String mask, Date date)
  2. convertDateToURLFormat(final String dateToBeConvert)
  3. convertStringoXSDString(Date date)
  4. convertTimeToString(Date date, String pattern)
  5. convertToString(Date date)
  6. convertToString(Date date, String style)
  7. convertToString(java.util.Date date)
  8. convertToString(String format, Date date)
  9. date2str(Calendar c)