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 04-14-2008, 12:03 PM
Member
 
Join Date: Mar 2008
Posts: 8
valoyivd is on a distinguished road
date and calender not getting the right results
Code:
public class TestDate { public static void main(String[] args) { Calendar calendar = Calendar.getInstance(); System.out.println("before 30***********" + calendar.get(Calendar.DAY_OF_MONTH)); calendar.add(Calendar.DAY_OF_MONTH, 30); System.out.println("after 30 **********" + calendar.get(Calendar.DAY_OF_MONTH)); int days = calendar.get(Calendar.DAY_OF_MONTH); System.out.println("days*************" + days); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-14-2008, 12:22 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Hello,

What you want to get?

calendar.get(Calendar.DAY_OF_MONTH) : It will return day....
if you want to add or subtract days then you will have to use

calendar.set(Calendar.DAY_OF_MONTH, 30)

Please clear you Question..??


sanjeev
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-14-2008, 12:24 PM
Member
 
Join Date: Mar 2008
Posts: 8
valoyivd is on a distinguished road
I want to get the days after adding 30 days....before is suppose to print the current date...and after is suppose to print the days after adding 30 days
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-14-2008, 12:34 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
See this code...

Code:
public static void testDate(){ Calendar calendar = Calendar.getInstance(); java.util.Date beforDate = calendar.getTime(); System.out.println("beforDate : " + beforDate); // Adding 30 Days to current Date. calendar.add(Calendar.DAY_OF_MONTH, 30); java.util.Date afterDate = calendar.getTime(); System.out.println("afterDate : " + afterDate); }


sanjeev
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-14-2008, 12:51 PM
Member
 
Join Date: Mar 2008
Posts: 8
valoyivd is on a distinguished road
that helps...thanks
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
BigInteger remainder results in zero perito New To Java 1 03-21-2008 05:07 PM
results to code disappear too fast for DOS window dubdubdub New To Java 3 12-29-2007 06:07 PM
java.util.Date vs java.sql.Date Jack New To Java 1 07-09-2007 04:22 AM


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


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