Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: problem Comparing date and month from dates

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem Comparing date and month from dates

    i am trying to write a code which compare current system date and month from a date obtained from database.
    for example
    system date is 6th may 2012
    and database date is 6th may 2010
    i want to compare only 6th may from both objects.
    please help with any example


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: problem Comparing date and month from dates

    Get the day of month and the month from each and compare those.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Mar 2012
    Location
    United States
    Posts
    118
    My Mood
    Inspired
    Thanks
    1
    Thanked 33 Times in 31 Posts

    Default Re: problem Comparing date and month from dates

    Have you actually created new Date objects using the data, or are they only String objects? If they are Date objects then look here:
    Date (Java 2 Platform SE v1.4.2)
    Specifically, the getDate() and getMonth() methods.

Similar Threads

  1. [SOLVED] Comparing Date Strings
    By wdh in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 26th, 2012, 03:28 AM
  2. [SOLVED] getting the end of the month for a given date
    By bczm8703 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 7th, 2011, 04:29 PM
  3. Replies: 1
    Last Post: July 22nd, 2011, 07:08 AM
  4. Comparing Two Dates
    By aussiemcgr in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 27th, 2011, 02:09 PM
  5. sql date problem
    By realosso in forum JDBC & Databases
    Replies: 2
    Last Post: June 3rd, 2010, 08:32 AM