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

  • SEARCH
  • Home
  • 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 7894395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:23:09+00:00 2026-06-03T07:23:09+00:00

Problem: I have a list containg hours, for example: 08:15:00 08:45:00 09:00:00 12:00:00 …

  • 0

Problem: I have a list containg hours, for example:
08:15:00
08:45:00
09:00:00
12:00:00
…
application is allowing user to make an appointment for a specific hour let’say: 8:15:00, each meeting takes half an hour.

Question: How to determine if there is a slot needed for appointment like this? I know that Calendar class have methods before() nad after(), but it doesn’solve my problem. I mean if there is appointment at 12:00 and another one at 12:00, how to prevent before making another one at 12:15?

edit:

I’ve tried using methods I mentioned before, like:

Calendar cal1 = Calendar.getInstance(); // for example 12:00:00
Calendar cal2 = Calendar.getInstance(); // for exmaple 12:30:00
Calendar userTime = Calendar.getInstance(); // time to test: 12:15:00

if(user.after(cal1)&& user.before(cal2)){
... // do sth
}
  • 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-03T07:23:10+00:00Added an answer on June 3, 2026 at 7:23 am

    Check if the date to check is between the two provided:

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm");
    Date before = sdf.parse("07/05/2012 08:00");
    Date after = sdf.parse("07/05/2012 08:30");
    Date toCheck = sdf.parse("07/05/2012 08:15");
    //is toCheck between the two?
    boolean isAvailable = (before.getTime() < toCheck.getTime()) && after.getTime() > toCheck.getTime();
    

    To book for a determinate hour, I would do a class with two dates and a method to check this:

    public class Appointment{
    
     private Date start;
     private Date end;
    
     public boolean isBetween(Date toCheck){....}
    
    }
    

    Then you can simply do an Schedule class extending ArrayList, adding a method isDateAvailable(Date toCheck), iterating the list of Appointments and checking that there is no one conflicting.

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

Sidebar

Related Questions

Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc
Example of the problem If I have a list of valid option strings which
I have created a test application to illustrate my problem. It parses a list
I need help with CMD scripts. Here is my problem: I have list of
The problem: I have a div where I will have a list of selections
Here is the problem: I have a list of items with various length for
Okay, so here's my problem: I have a list of members on a website,
The problem is: I have a list of objects, with some containing the same
I have a problem with random and arrays. I have a list empty list
I have problem adding arraylist to list view, will explain about my problem here..

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.