Java Timestamp add(Timestamp ts, int field, int amount)

Here you can find the source of add(Timestamp ts, int field, int amount)

Description

add

License

Apache License

Declaration

public static Timestamp add(Timestamp ts, int field, int amount) 

Method Source Code

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

import java.util.*;
import java.sql.Timestamp;

public class Main {
    public static Timestamp add(Timestamp ts, int field, int amount) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(ts);//from  ww  w  .jav  a 2s  . com
        cal.add(field, amount);
        Timestamp ts2 = new Timestamp(cal.getTime().getTime());
        return ts2;
    }
}

Related

  1. add(Timestamp target, int addNum, int addKind)
  2. addDate(Timestamp date, String type, int into)
  3. addDays(Timestamp date, int days)
  4. addDays(Timestamp day, int offset)
  5. addDaysToTimestamp(Timestamp start, int days)