• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

checking for date

 
lynn fann
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to check whether the date is 6 month ago from the today date. How should i check it?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the Calendar class
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the documentation for class java.util.Calendar. With that class, you can do this:
  • Get an instance of Calendar that represents the current date and time
  • Subtract 6 months from the current date and time of the Calendar
  • Compare the date and time of the Calendar to that of a Date object

  • So have a look at class Calendar and try to write some code. If you have more questions, please ask them here.
    [ March 21, 2007: Message edited by: Jesper Young ]
     
    lynn fann
    Ranch Hand
    Posts: 115
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    i know is using calendar class. i dont know how to substract 6 month. is it that i have to get the milliseconds for 6 mth, and use the current to substract?
     
    Garrett Rowe
    Ranch Hand
    Posts: 1296
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Have you taken a look at the Calendar.add()?
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic