Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
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. 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

                         

» View all related tutorials
Related Tags: c class ant help property get tutorial name ria this for to e des pe in as sta m nt

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.