Java Date to String dateToFormattedString(Date toFormat)

Here you can find the source of dateToFormattedString(Date toFormat)

Description

Converts a Date-Object to a String with the format of the DATEPATTERN

License

Open Source License

Parameter

Parameter Description
toFormat a parameter

Declaration

public static String dateToFormattedString(Date toFormat) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**//from  w  w w. jav a  2 s .c  o  m
     * Defines the format of each string that represent a date in our project.
     * The pattern is "dd.MM.yyyy HH:mm:ss"
     */
    public static final String DATEPATTERN = "dd.MM.yyyy HH:mm:ss";

    /**
     * Converts a Date-Object to a String with the format of the DATEPATTERN
     * @param toFormat
     * @return
     */
    public static String dateToFormattedString(Date toFormat) {
        return new SimpleDateFormat(DATEPATTERN).format(toFormat);
    }
}

Related

  1. dateToCalendar(Date fecha, String formato)
  2. dateToDateString(Date date, Locale locale)
  3. dateToDDMMYYYYStr(Date dateTime)
  4. dateToDefaultDateString(Date date)
  5. dateToFMDate(Date date)
  6. dateToHHmmStr(Date date)
  7. dateToHMTime(Date date)
  8. dateToHttpDateString(Date d)
  9. dateToHuman(Date date)