Java Second Add addSecond(Date date, int number)

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

Description

add Second

License

Open Source License

Declaration

public static Date addSecond(Date date, int number) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static Date addSecond(Date date, int number) {
        Calendar calendar = getDefaultCalendar();
        calendar.setTime(date);//from  w ww . ja  v  a2  s .  co  m
        calendar.add(Calendar.SECOND, number);
        return calendar.getTime();
    }

    /**
     * get the default calendar
     *
     * @return the calendar instance
     */
    public static Calendar getDefaultCalendar() {
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        return calendar;
    }
}

Related

  1. addOrMinusSecond(long ti, int i)
  2. addSecond(Date date, int n)
  3. addSecond(Date date, int numberOfSecond)
  4. addSecond(Date date, int second)
  5. addSecond(Date source, int s)
  6. addSecond(int second)