Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2007, 07:14 PM
Member
 
Join Date: Dec 2007
Posts: 1
senzacionale is on a distinguished road
date one month back
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
java.util.Date date = new java.util.Date();
String datetime= dateFormat.format(date);

like this i get current date. How i can get date one months back?

regards
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-24-2007, 10:02 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,022
hardwired is on a distinguished road
Code:
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Date date = new Date(); System.out.println("date = " + dateFormat.format(date)); // get date one months back Calendar calendar = Calendar.getInstance(); System.out.println("current calendar time = " + dateFormat.format(calendar.getTime())); calendar.add(Calendar.MONTH, -1); System.out.println("calendar one month back = " + dateFormat.format(calendar.getTime()));
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between current date and anothe date vijay balusamy New To Java 1 04-16-2008 05:15 PM
Datepicker Calender - month change event - jquery rmpatel101 Advanced Java 0 04-02-2008 07:42 PM
Month and year program code!!!!HELP PLEASE!!! chitwood New To Java 0 02-10-2008 09:23 PM
Current month Java Tip Java Tips 0 01-07-2008 09:40 AM
Switch statement to display the name of the month Java Tip Java Tips 0 01-04-2008 10:32 AM


All times are GMT +3. The time now is 10:45 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org