Java Second Add addSecond(Date source, int s)

Here you can find the source of addSecond(Date source, int s)

Description

add Second

License

Apache License

Declaration

public static Date addSecond(Date source, int s) 

Method Source Code

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

import java.util.Calendar;

import java.util.Date;

public class Main {
    public static Date addSecond(Date source, int s) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(source);//from   www. j  a v a2s . co  m
        cal.add(Calendar.SECOND, s);

        return cal.getTime();
    }

    public static Long getTime(int length, Date date) {
        String time = String.valueOf(date.getTime()).substring(0, length);
        return Long.parseLong(time);
    }
}

Related

  1. addOrMinusSecond(long ti, int i)
  2. addSecond(Date date, int n)
  3. addSecond(Date date, int number)
  4. addSecond(Date date, int numberOfSecond)
  5. addSecond(Date date, int second)
  6. addSecond(int second)
  7. addSeconds(Date date, int seconds)
  8. addSeconds(Date date, int seconds)
  9. addSeconds(final Date date, final int seconds)