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 8951709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:43:38+00:00 2026-06-15T13:43:38+00:00

Actually in my java program User give Start Date and end Date ex:2012-12-01 and

  • 0

Actually in my java program User give Start Date and end Date ex:2012-12-01 and 2012-12-30 and Now we can give result back to between dates of Start date and end date.

If we want every day we can give using the following code…

List<Date> dates = new ArrayList<Date>();
     DateFormat formatter = new SimpleDateFormat("yyyy-mm-dd");
    String str_date ="2012-12-03";
    String end_date ="2012-12-06";
    Date startDate = (Date) formatter.parse(str_date);
    Date endDate = (Date) formatter.parse(end_date);

    Calendar cal = Calendar.getInstance();
    Calendar cal1 = Calendar.getInstance();
    cal.setTime(startDate);
    cal1.setTime(endDate);
    int i=0; // use this for alternative date print
    while (!cal.equals(cal1)) {

        cal.add(Calendar.DATE, 1);
             System.out.println(cal.getTime()); 

        }

But it is not the case the Problem is User want only Monday,sunday dates in his Start date and end Date then How to check that one….

For Ex: String userWeeks="SUNDAY,MONDAY";

This is User String then How to Compare Calendar Dates into this userWeeks string.

First thing we can Split the String userWeeks.split(",") then we get separate SUNDAY MONDAY

So How to compare This String into Calendar?
  • 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-15T13:43:39+00:00Added an answer on June 15, 2026 at 1:43 pm

    Finally i’m thinking this way is there any issues of my code Please discuss me..

        import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    
    
    public class SimpleDateFormatClass 
    {
        public static void main(String args[]) throws Exception
        {
             DateFormat formatter = new SimpleDateFormat("yyyy-mm-dd");
                String str_date ="2012-12-01";
                String end_date ="2012-12-10";
                Date startDate = (Date) formatter.parse(str_date);
                Date endDate = (Date) formatter.parse(end_date);
                Calendar cal = Calendar.getInstance();
                Calendar cal1 = Calendar.getInstance();
                cal.setTime(startDate);
                cal1.setTime(endDate);
        while (!cal.equals(cal1))
        {       
                    cal.add(Calendar.DATE, 1);      
    
             String days="Fri,mon,tue";
              for (String retval: days.split(","))
                {
            SimpleDateFormat sdf= new SimpleDateFormat("EEEE");
            Date date1= sdf.parse(retval);
    
                  if(date1.getDay()==cal.get(Calendar.DAY_OF_WEEK))
                      {
                           System.out.println(cal.getTime());
                      }
               // System.out.println(date1);
               }
        }//While
        }//Main
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webcam (actually 3) and java program to capture the frames. However,
I have written a java program that is actually works as a gui to
I'm trying to make a program in Java that can read, compile, and run
I am writing a Java program to read and XML file, actually an iTunes
I have a Java program which has a number options it allows the user
my java program want TimeZone like GMT(+0530) instead of getting IST Actually my java
i've a Java program that print out some text output. Actually my simple PrintOutput
Possible Duplicate: How can I convert my Java program to an .exe file? Compiling
I have an XSLT Transformer in Java (actually its Apache FOP rendering to PDF)
I am a total total beginner in Java actually I am .net dev trying

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.