Java Date to String date2string(Date date)

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

Description

Utility routine to convert a date to a string.

License

Open Source License

Parameter

Parameter Description
date Date to convert

Return

Formatted string

Declaration

public static String date2string(Date date) 

Method Source Code

//package com.java2s;
/*/*ww w  .ja v  a  2s .c  o m*/
 * @copyright 2012 Philip Warner
 * @license GNU General Public License
 * 
 * This file is part of Book Catalogue.
 *
 * TaskQueue is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TaskQueue is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Book Catalogue.  If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    /** Date format used in displaying and parsing dates in the database */
    private static final DateFormat m_stdDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**
     * Utility routine to convert a date to a string.
     * 
     * @param date   Date to convert
     * @return      Formatted string
     */
    public static String date2string(Date date) {
        return m_stdDateFormat.format(date).toString();
    }
}

Related

  1. date2String(Date date)
  2. date2String(Date date)
  3. date2String(Date date)
  4. date2String(Date date)
  5. date2String(Date date)
  6. date2String(Date date)
  7. date2String(Date date, DateFormat dateFormat)
  8. date2String(Date date, int _iType)
  9. Date2String(Date date, String DateFormat)