Java Date Format formatDate(Date date)

Here you can find the source of formatDate(Date date)

Description

Formats a Date object to return a date using the global locale.

License

LGPL

Declaration

public static String formatDate(Date date) 

Method Source Code

//package com.java2s;
/**//from   w  ww .  ja va2s  .  c o  m
 * Converts a line of text into an array of lower case words using a
 * BreakIterator.wordInstance().
 * <p>
 *
 * This method is under the Jive Open Source Software License and was
 * written by Mark Imbriaco.
 *
 * @param text
 *            a String of text to convert into an array of words
 * @return text broken up into an array of words.
 */

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

public class Main {
    public static String formatDate(Date date, String format) {
        SimpleDateFormat outFormat = new SimpleDateFormat(format);
        return outFormat.format(date);
    }

    /**
     * Formats a Date object to return a date using the global locale.
     */
    public static String formatDate(Date date) {
        SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd");
        return outFormat.format(date);
    }
}

Related

  1. formatDate(Date date)
  2. formatDate(Date date)
  3. formatDate(Date date)
  4. formatDate(Date date)
  5. formatDate(Date date)
  6. formatDate(Date date)
  7. formatDate(Date date)
  8. formatDate(Date date, DateFormat dateFormat, char delimiter, boolean endWithDelimiter)
  9. formatDate(Date date, Locale locale)