Results 1 to 7 of 7
  1. #1
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default Converting Date into int

    Hi. I want to get the current date as an int.. I can get it as a Date object but I want to convert it into an int so I can do mathematical manipulation on it.
    Thanks!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    Have you read the API doc for the Date class for a useful method? Is there one the can help you?

  3. #3
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    I can use this to
    Date date= new Date();
    long longDate=date.getTime();
    But it's giving me an error! :s

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default

    But it's giving me an error! :s
    Please post the error.

  5. #5
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    ok it worked!
    Dont know what was wrong!
    Thanks alot! :D

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default

    Quote Originally Posted by Rami View Post
    Hi. I want to get the current date as an int.. I can get it as a Date object but I want to convert it into an int so I can do mathematical manipulation on it.
    Thanks!
    I think what you really need is Calendar and its method add(...)

    db

  7. #7
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    EXACTLY!
    It worked with me but in millisec since Jan 1st 1970!
    But the add is much much better!
    THANKS ALOT!

Similar Threads

  1. Replies: 5
    Last Post: 02-16-2012, 10:26 AM
  2. Replies: 5
    Last Post: 01-25-2011, 07:00 AM
  3. Replies: 1
    Last Post: 10-15-2010, 09:58 AM
  4. converting string (GMT date) to date in US time.
    By JRuyechan in forum New To Java
    Replies: 1
    Last Post: 10-15-2010, 08:07 AM
  5. Converting Epoch to string Date
    By amyedwards in forum New To Java
    Replies: 3
    Last Post: 12-14-2007, 11:33 PM

Posting Permissions

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