Java Locale Format formatDate(java.util.Date date, String formatPattern)

Here you can find the source of formatDate(java.util.Date date, String formatPattern)

Description

formatDate Returns the formatted date according to the input pattern.

License

Open Source License

Parameter

Parameter Description
date The date going to be formatted.
formatPattern The format pattern.

Return

The formatted date according to the input pattern.

Declaration

public static String formatDate(java.util.Date date, String formatPattern) 

Method Source Code

//package com.java2s;
/*//from   w w  w. ja  v a 2 s  . c om
 * @(#)TextUtility.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

public class Main {
    /**
     * formatDate
     *
     * Returns the formatted date according to the input pattern.
     *
     * @param   date The date going to be formatted.
     * @param   formatPattern The format pattern.
     * @return  The formatted date according to the input pattern.
     */
    public static String formatDate(java.util.Date date, String formatPattern) {
        if (date == null) {
            return "";
        }
        java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(formatPattern,
                new java.util.Locale("en", "US"));
        return (formatter.format(date));
    }
}

Related

  1. formatDate(final Date date, final String datepattern, TimeZone tz)
  2. formatDate(final Date date, final String format)
  3. formatDate(final Date date, final String pattren)
  4. formatDate(java.util.Date d, String format)
  5. formatDate(java.util.Date d, String format)
  6. formatDate(String _Date)
  7. formatDate(String dateStr, String format, String toFormat)
  8. formatDate(String pattern, Date date, String valueForNull)
  9. formatDate(String strDate, Locale locale)