Monday, June 29, 2015

my{} JAVA date incriment decrement

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;
import java.util.Calendar;
import java.util.Scanner;
import java.io.Console;

/**
 *
 * @author class
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    
    public static void main(String[] args) {

      // create a calendar
      Calendar cal = Calendar.getInstance();

      // print current time
      System.out.println("Current year is :" + cal.getTime());

      // set the year,month and day to something else

     cal.add(Calendar.DAY_OF_MONTH, -5);

      // print the result
      System.out.println("-5 days prior :" + cal.getTime());
   }
}
    

/*
 * 
 * Scanner reader = new Scanner(System.in);
System.out.println("Enter the first number");
//get user input for a
a=reader.nextInt();
 * 
 * 
 * Console console = System.console();
String input = console.readLine("Enter input:");
 */

No comments:

Post a Comment