wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes checking for date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "checking for date" Watch "checking for date" New topic
Author

checking for date

lynn fann
Ranch Hand

Joined: Oct 15, 2006
Posts: 115
i need to check whether the date is 6 month ago from the today date. How should i check it?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Use the Calendar class


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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 ]

    Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
    Scala Notes - My blog about Scala
    lynn fann
    Ranch Hand

    Joined: Oct 15, 2006
    Posts: 115
    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

    Joined: Jan 17, 2006
    Posts: 1296
    Have you taken a look at the Calendar.add()?


    Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: checking for date
     
    Similar Threads
    Book for database design
    Running self made Servlets on tomcat
    Modulus 10
    Seam beginner need help
    compare dates which are in string variable in javascript