Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
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
  #21 (permalink)  
Old 05-16-2008, 09:46 AM
Member
 
Join Date: Jan 2008
Posts: 83
Preethi is on a distinguished road
I have two dates:05/05/2008 and 05/10/2009
I want to find the 86th date between the two dates..How can,i...Please help me..
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 05-16-2008, 09:51 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 228
Eku is on a distinguished road
Just Exactly how? 86th from both dates? could you explain more. =P
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #23 (permalink)  
Old 05-16-2008, 10:25 AM
Member
 
Join Date: Jan 2008
Posts: 83
Preethi is on a distinguished road
I have two dates:05/05/2008 and 05/10/2009
I want to find what 'll be the 86th date between the two date...How to get it?Can you please help me?
Bookmark Post in Technorati
Reply With Quote
  #24 (permalink)  
Old 05-16-2008, 10:47 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 228
Eku is on a distinguished road
Thats a little tricky on me. Here is my suggestion.

Convert the Date into Int first. (NOTE: You can use String manipulation and Parse it to get int). Then Do a regular Mathematical equation on Days, month,and year. But you need to keep in mind that not all months have 30 days. =) This is a long code to it. But this what i can think off. I hope it helps
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #25 (permalink)  
Old 05-16-2008, 03:06 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 187
rjuyal is on a distinguished road
i think you want a date which is

86 days after 05/05/2008.
let me know if i am correct!
__________________
i am the future
Bookmark Post in Technorati
Reply With Quote
  #26 (permalink)  
Old 05-16-2008, 07:11 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Quote:
i think you want a date which is

86 days after 05/05/2008.
let me know if i am correct!
If that is,

GregorianCalendar will do the rest....

there is a constructor with parameters (year,month,date)
the value will then set into that date carrying a long value....

there is also a method there getTimeInMillis() that returns the updated long value that represents the date base on what value did you initialized at the constructor....

add an equivalent of 86 days ( 86 * 86,400,000 milliseconds ) to that updated long value....

You have to set the current time again by using
setTimeInMillis(long value) and that value should be the calculated one....

The current time is updated.....
you can now use get(int field) that returns an integer value representation of a specific date.... field is from GregorianCalendar class' constants....

by using those constants from the get(int field), you can have now an integer representation...

eg. YEAR returns 20XX
MONTH returns ( i doubt, try to test it... i think it starts from 1 to 12)
DATE returns from 1 to 31 ( try to test it )

If you like to format it in Strings, you can use SimpleDateFormat class...

Hope this helps,
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 05-17-2008 at 03:59 PM.
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
java.util.Date vs java.sql.Date Jack New To Java 3 12-18-2008 11:37 PM
Creating a Gregorian Calendar using a Date object gives date - 1 prachi_goliwadekar New To Java 1 05-08-2008 10:32 PM
Difference between current date and anothe date vijay balusamy New To Java 1 04-16-2008 06:15 PM
Using java.sql.Date Java Tip Java Tips 0 02-10-2008 01:32 PM
Java Date levent Java Tutorials 0 08-05-2007 03:57 AM


All times are GMT +3. The time now is 05:21 AM.


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