Java SQL Time Calculate addTimeToDate(Date dt)

Here you can find the source of addTimeToDate(Date dt)

Description

Adds the time to date.

License

Apache License

Parameter

Parameter Description
dt the dt

Return

the timestamp

Declaration

public static Timestamp addTimeToDate(Date dt) 

Method Source Code


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

import java.sql.Timestamp;

import java.util.Date;

public class Main {
    /**//from   w w  w  .j  a va 2s  .  co  m
     * Adds the time to date.
     * 
     * @param dt
     *            the dt
     * @return the timestamp
     */
    public static Timestamp addTimeToDate(Date dt) {
        Timestamp dateVal = null;
        try {
            if (dt != null) {
                long onedayminusonesec = (24 * 60 * 60 * 1000) - 10;
                dateVal = new Timestamp(dt.getTime() + onedayminusonesec);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dateVal;
    }
}

Related

  1. getDifference(Time timeFrom, Time timeTo)
  2. getDiffTime(String _fromDate, String _fromTime, String _toDate, String _toTime)
  3. getExpiresTime(Long validityPeriod)
  4. addTime(String date, String type, int into, String pattern)
  5. addTime(Time time, int minutes)
  6. addDateTime(String date, String type, int into)
  7. appendTime(StringBuffer sb, Calendar cal, int nanos)