Java Date to Timestamp getTimestamp(Date date)

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

Description

get Timestamp

License

LGPL

Declaration

public static Timestamp getTimestamp(Date date) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.sql.Timestamp;
import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Timestamp getTimestamp(long millis) {
        return new Timestamp(millis);
    }/* www  .j a va 2s .c om*/

    public static Timestamp getTimestamp(String time) {
        return new Timestamp(Long.parseLong(time));
    }

    public static Timestamp getTimestamp() {
        return new Timestamp(new Date().getTime());
    }

    public static Timestamp getTimestamp(Date date) {
        return new Timestamp(date.getTime());
    }

    public static Timestamp gettimestamp() {
        Date dt = new Date();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String nowTime = df.format(dt);
        java.sql.Timestamp buydate = java.sql.Timestamp.valueOf(nowTime);
        return buydate;
    }
}

Related

  1. getAuditTimestamp(Date date)
  2. getDetailedTimeStamp(Date date)
  3. getDisplayableTimeStamp(Date timeStamp)
  4. getDisplayTimeStamp(Date date)
  5. getJnlpTimestamp(Date date)
  6. getTimestamp(Date date)
  7. getTimestamp(Date date)
  8. getTimestamp(Date date)
  9. getTimestamp(Date date)