Java Date Format convertDateToString(Date date, String pattern)

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

Description

convert Date To String

License

Open Source License

Declaration

public static String convertDateToString(Date date, String pattern) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";

    public static String convertDateToString(Date date) {
        return convertDateToString(date, DEFAULT_DATE_FORMAT);
    }//w  w w  .  j a  v  a 2s.com

    public static String convertDateToString(Date date, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
}

Related

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