Get Tomorrow Date

In this Tutorial we want to describe you a code that help you in understanding Get Tomorrow Date.

Get Tomorrow Date

In this Tutorial we want to describe you a code that help you in understanding Get Tomorrow Date.

Get Tomorrow Date

Get Tomorrow Date

     

In this Tutorial we want to describe you a code that help you  in understanding Get Tomorrow Date. For this we have a class name GetTomorrowDate.Inside the main method we have a variable name string s,Date date, Format formatter. The Calendar class has a method get Instance method() returns you the calendar object with a specific time zone and locale. . The calendar object call the get time () method that return you the current time and store in a variable date. and store in a formatter. The format class is abstract base class that is used for formatting the local sensitive object to a string. The formatter variable call format method to return a format object to a string.. The System.out.println print the current date. The calendar class has a add() method that  add the next date in the calendar. In the same way the calendar call the get Time Method to return a current time and store in  a date variable. The format method format the current time  in a specified format passed as argument in simpledateformat and store in a string variable. Finally The println print the next day i.e. tomorrow on the command prompt.

1)calendar.getInstance ( )-This method return you the calendar object with a specific time zone and locale.

2)SimpleDateFormat- is a  formatting concrete class that helps you in parsing date in a locale-sensitive manner. This allows you to format (date -> text), parsing (text -> date), and normalization.

3)calendar.getTime ( )  - This method returns the number of the millisecond elapsed since January1,1971.

GetTomorrowDate.java
import java.util.*;
import java.text.*;

public class GetTomorrowDate {

  public static void main(String args[]) {

  String s;
  Date date;
  Format formatter;
  Calendar calendar = Calendar.getInstance();

  date = calendar.getTime();
  formatter = new SimpleDateFormat("dd/MMM/yyyy");
  s = formatter.format(date);
  System.out.println("Today : " + s);

  calendar.add(Calendar.DATE, 1);
  date = calendar.getTime();
  formatter = new SimpleDateFormat("dd/MMM/yyyy");
  s = formatter.format(date);
  System.out.println("Tomorrow : " + s);
  }
}

Output
Today : 03/Nov/2008
Tomorrow : 04/Nov/2008
Download code