Java Date to Timestamp timestamp(Date dateAndTime)

Here you can find the source of timestamp(Date dateAndTime)

Description

Return a string holding the time and date in the form:
 Thursday, May 29, 2003 11:42:44 AM 

License

Open Source License

Declaration

static public String timestamp(Date dateAndTime) 

Method Source Code


//package com.java2s;
/* The DateUtil utility provides several workhorse methods that
 * use Java's formatters to parse and format dates, times, etc.
 *
 * <!-- ====================== distribution terms ===================== -->
 * <p><blockquote//from   w ww  . ja  va 2 s .  co m
 *    style="border-style: solid; border-width:thin; padding: 1em 1em 1em 1em;">
 * <center>
 *          Copyright &copy; 2003, Allen I. Holub. All rights reserved.
 * </center>
 * <br>
 * <br>
 *       This code is distributed under the terms of the
 *       <a href="http://www.gnu.org/licenses/gpl.html"
 *       >GNU Public License</a> (GPL)
 *       with the following ammendment to section 2.c:
 *       <p>
 *       As a requirement for distributing this code, your splash screen,
 *       about box, or equivalent must include an my name, copyright,
 *       <em>and URL</em>. An acceptable message would be:
 * <center>
 *       This program contains Allen Holub's <em>XXX</em> utility.<br>
 *             (c) 2003 Allen I. Holub. All Rights Reserved.<br>
 *                   http://www.holub.com<br>
 * </center>
 *       If your progam does not run interactively, then the foregoing
 *       notice must appear in your documentation.
 * </blockquote>
 * <!-- =============================================================== -->
 * @author Allen I. Holub
 */

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

public class Main {
    /** Return a string holding the time and date in the form:
     *  <pre>
     *   Thursday, May 29, 2003 11:42:44 AM
     *  </pre>
     */
    static public String timestamp(Date dateAndTime) {
        return DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM).format(dateAndTime);
    }
}

Related

  1. getTimeStamp(Date date, String time)
  2. removeTimestamp(Date date)
  3. timestamp(Calendar date)
  4. timestamp(Date d)
  5. timeStamp(Date date)
  6. timestampSec(Date date)
  7. TimestampToString(Date thisdate)
  8. toDate(String timeStamp)
  9. toDateStringFromResources(String timestamp)