Java Second Calculate nextSecond(int second)

Here you can find the source of nextSecond(int second)

Description

next Second

License

Artistic License

Declaration

public static Date nextSecond(int second) 

Method Source Code


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

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public class Main {
    public static Date nextSecond(int second) {
        Calendar now = now();//  w  w  w  .  j  ava 2  s . co  m

        now.set(Calendar.SECOND, now.get(Calendar.SECOND) + second);

        return now.getTime();
    }

    public static Calendar now() {
        Calendar now = new GregorianCalendar();
        now.setTimeInMillis(new Date().getTime());
        now.setTimeZone(TimeZone.getDefault());

        return now;
    }
}

Related

  1. computeStartOfNextSecond(long now)
  2. getMillisecond(long num, int unit)
  3. getSecond(long t)
  4. getSecond(String s)
  5. secondsLater(Integer seconds)