Java Timestamp addMilli(Timestamp nowDate, int period)

Here you can find the source of addMilli(Timestamp nowDate, int period)

Description

addMilli.

License

Open Source License

Parameter

Parameter Description
nowDate Date
period integer

Return

Timestamp

Declaration


public static Timestamp addMilli(Timestamp nowDate, int period) 

Method Source Code


//package com.java2s;
/*/*from w w w . ja v a2 s  .c  o  m*/
 * Copyright (C) 2010 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.sql.Timestamp;

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**
     * addMilli.<br>
     *
     * @param nowDate Date
     * @param period integer
     * @return Timestamp
     */
    //==========================================================================
    public static Timestamp addMilli(Timestamp nowDate, int period) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(nowDate);
        calendar.add(Calendar.MILLISECOND, period);

        Timestamp stopTerm = date2Timestamp(calendar.getTime());

        return stopTerm;
    }

    /**
     *
     * @param value Date
     * @return Timestamp
     */
    public static Timestamp date2Timestamp(Date value) {
        if (value != null) {
            return new Timestamp(value.getTime());
        }
        return null;
    }
}

Related

  1. addDays(Timestamp day, int offset)
  2. addDaysToTimestamp(Timestamp start, int days)
  3. addDaysToTimestamp(Timestamp timestamp, int numDays)
  4. addHours(Timestamp date, int numOfHours)
  5. addHoursToTimestamp(Timestamp start, int hours)
  6. addMonth(java.sql.Timestamp src, int val)
  7. addMonths(Timestamp refDate, int nrOfMonthsToAdd)
  8. addTime(java.sql.Timestamp start, int year, int month, int day)
  9. adjustTimestamp(Timestamp stamp, int adjType, int adjQuantity, TimeZone timeZone, Locale locale)