Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:18:39+00:00 2026-06-13T04:18:39+00:00

while (r.next()) { String rn = r.getString(3); String sqldate = r.getString(2); // database reservation

  • 0
while (r.next()) {
    String rn = r.getString(3);
    String sqldate = r.getString(2); // database reservation date
}

Getting date from database

DateFormat RD = new SimpleDateFormat("yyyy-MM-dd");
     java.sql.Date converteddate = new java.sql.Date(RD.parse(sqldate).getTime());
     Calendar cal = Calendar.getInstance();
     Calendar cal1 = Calendar.getInstance();
     cal.setTime(converteddate);
     cal.add(Calendar.DATE, 7);
     if(cal<=cal1){ }// i need to this opration i dont know how

I need to check cal is <= Cal1. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:18:40+00:00Added an answer on June 13, 2026 at 4:18 am

    How about using the simple method:

    if (cal.before(cal1)) { ... }
    

    This reads: “If a date is before another date, you should do the following..”.

    I think it makes it easier to read if you write “before” than “compareTo”, even though the operation is the same. Also read the documentation for Java Calendar.

    EDIT:
    I’ve updated the answer a bit to include what’s been commented below so the answer is more complete. Thanks to assylias for pointing it out, but if you want to compare if a date is before or equal to another date, you should use:

    if (!cal.after(cal1)) { ... }
    

    This reads: “If a date is not after another date, you should do the following..”. Also note that “not after” is the same as “before or equal to”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

while (rs.next()) { String rn = rs.getString(3); String sqldate = rs.getString(2); // database reservation
Any ideas why this isnt working? DateFormat df = new SimpleDateFormat(dd/mm/yyyy); Date date1 =
myRs=myStmt.executeQuery(select i_col,col_name from tab_col) i=0 while (myRs.next()): list= myRs.getString(I_COL)+','+myRs.getString(COL_NAME) i have a jython code
i need to store a DatSet value into ArrayList while(result.next()) { String Adress= result.getString(1);
i have the next code: std::string line; std::ifstream myfile (text.txt); if (myfile.is_open()) { while
I have the following code: String table; private DB.ConnectMAS mas=new DB.ConnectMAS(); java.sql.ResultSet rs1 =
I'm trying to select data from database using this code: //DATABASE ResultSet rs; String
$(.sectionHeader).click(function() { var row = $(this).parent(); while (row.next().length != 0) { row = row.next();
Statement stmt=conn.createStatement(); //1 Statement stmt2=conn.createStatement(); //2 ResultSet resultSet1=stmt.executeQuery(-----); //3 while(resultSet1.next()) { //4 ResultSet resultSet2
Im trying to make a basic while loop example im preperation for my next

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.