Java Calendar add subtract seconds

Description

Java Calendar add subtract seconds

import java.util.Calendar;

public class Main {

  public static void main(String[] args) {
    Calendar now = Calendar.getInstance();

    System.out.println("Current date : " + now.getTime());


    now.add(Calendar.SECOND, 999990);

    System.out.println(now.getTime());

    now = Calendar.getInstance();
    now.add(Calendar.SECOND, -1999990);

    System.out.println( now.getTime());

  }/*www. j av a  2 s.  com*/
}



PreviousNext

Related