Display Current Date & Time and Adds or subtracts Days from Current Date

Here the Java code that display the current date & time as well as by adding and subtracting the days from the current date. 
  1. import java.util.Calendar;  
  2. public class Table {  
  3.     public static void main(String[] args) {  
  4.         int second, minute, hour;  
  5.         //create Calendar instance  
  6.         Calendar now = Calendar.getInstance();  
  7.         //display current date (dd-mm-yyyy)  
  8.         System.out.println("Current date : " + now.get(Calendar.DATE) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.YEAR));  
  9.         //display current time  
  10.         second = now.get(Calendar.SECOND);  
  11.         minute = now.get(Calendar.MINUTE);  
  12.         hour = now.get(Calendar.HOUR);  
  13.         System.out.println("Current time is " + hour + " : " + minute + " : " + second);  
  14.         //add days to current date  
  15.         now.add(Calendar.DATE, 1);  
  16.         System.out.println("date after one day : " + now.get(Calendar.DATE) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.YEAR));  
  17.         //subtract days from current date  
  18.         now = Calendar.getInstance();  
  19.         now.add(Calendar.DATE, -10);  
  20.         System.out.println("date before 10 days : " + now.get(Calendar.DATE) + "-" + (now.get(Calendar.MONTH) + 1) + "-" + now.get(Calendar.YEAR));  
  21.     }  
  22. }  
Thank you, keep learning and sharing