Java Calendar add subtract hours

Description

Java Calendar add subtract hours

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.HOUR, 100);//w  w w .j  a  v a2 s .co  m

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

    now = Calendar.getInstance();
    now.add(Calendar.HOUR, -100);

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

  }
}



PreviousNext

Related