Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26
  1. #21
    Preethi is offline Member
    Join Date
    Jan 2008
    Posts
    83
    Rep Power
    0

    Default

    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..

  2. #22
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    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.

  3. #23
    Preethi is offline Member
    Join Date
    Jan 2008
    Posts
    83
    Rep Power
    0

    Default

    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?

  4. #24
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    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.

  5. #25
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    i think you want a date which is

    86 days after 05/05/2008. :D
    let me know if i am correct!
    i am the future

  6. #26
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    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,
    Last edited by sukatoa; 05-17-2008 at 02:59 PM.
    freedom exists in the world of ideas

Page 2 of 2 FirstFirst 12

Similar Threads

  1. java.util.Date vs java.sql.Date
    By Jack in forum New To Java
    Replies: 5
    Last Post: 10-28-2010, 03:59 PM
  2. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 09:32 PM
  3. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 05:15 PM
  4. Using java.sql.Date
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 12:32 PM
  5. Java Date
    By levent in forum Java Tutorial
    Replies: 0
    Last Post: 08-05-2007, 02:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •