Java Locale Format formatDate(Date date, String format)

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

Description

format Date

License

LGPL

Declaration

public static String formatDate(Date date, String format) 

Method Source Code

//package com.java2s;
/**/*from  w w  w  .java  2  s. c  om*/
 * 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. formatBytes(final long bytes)
  2. formatBytes(long byteCount, Locale locale)
  3. formatBytesForDisplay(long amount)
  4. formatComma(String number)
  5. formatDate(Calendar cal, String format)
  6. formatDate(Date date, String format)
  7. formatDate(Date date, String format, String localeText)
  8. formatDate(Date date, String pattern)
  9. formatDate(Date date, String pattern)