Solved

Using date properties?

Posted on 2004-10-14
11
176 Views
Last Modified: 2010-03-31
I want to read a file if it is created between a particular period.The user selects the from and to fields.We compare these two fields with the date in the file.

This is what I am currently doing...

if(rD.after(toDate) && rD.before(tfromDate)){

read the file

}

If the user enters july 01 2004 as the from field, the files are being read from july 02 2004. Can you please help me with this issue?

Thanks,
0
Comment
Question by:g46905
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12312940
if (rD.compareTo(toDate)<=0 && rD.compareTo(tfromDate)>=0)
0
 

Author Comment

by:g46905
ID: 12313831
It is still not reading the file created on that partucular date.

This is what I am using

  rD : Wed Sep 01 00:00:00 CDT 2004 // the file created on the same date as fromDate is not being read.
 fromDate : Wed Sep 01 00:00:00 CDT 2004
 ToDate : Thu Sep 30 23:59:59 CDT 2004

if ((rD.compareTo(toDDDDt)<=0) && (rD.compareTo(frDDDDt)>=0))

Any ideas would be greatly appreciated.

Thanks,
0
 
LVL 92

Expert Comment

by:objects
ID: 12313856
can you run this and post the output:

System.out.println(rD);
System.out.println(frDDDDt);
System.out.println(toDDDDt);
System.out.println(rD.compareTo(toDDDDt));
System.out.println(rD.compareTo(frDDDDt));
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:g46905
ID: 12315625
Object,
          Here are the results that you have asked me for


 rD : Wed Sep 01 00:00:00 CDT 2004
 frDDDDt : Wed Sep 01 00:00:00 CDT 2004
 toDDDDt : Thu Sep 30 23:59:59 CDT 2004
 rD.compareTo(toDDDDt) : -1
 rD.compareTo(frDDDDt) -1

Please let me know if you want me to try something else.Thanks for your help!

Thanks again,
0
 
LVL 92

Expert Comment

by:objects
ID: 12315841
post the results of this:

System.out.println(rD.getTime());
System.out.println(frDDDDt.getTime());
0
 

Author Comment

by:g46905
ID: 12316028
System.out.println(rD.getTime());

=>  1094014800000

System.out.println(frDDDDt.getTime());

=>  1094014800219

Please lte me know if you want me to test something.

Thanks
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 12316061
the date isn't actually between those two dates, it is 219 msecs before frDDDDt .
0
 

Author Comment

by:g46905
ID: 12317931
This is how I set the fromDate

cs.set(yyyy, mm, dd, 0, 0, 0);

Could you please share your thoughts on the changes that needs to take place to resolve the above mentioned issue.

Thanks,
0
 

Author Comment

by:g46905
ID: 12317983
I want the milliseconds to be a default value of 0 all the time for the fromDate. Can you please suggest?

Thanks
0
 

Author Comment

by:g46905
ID: 12318080
I have made the change required and was able to set the milliseconds to default 0.Thanks for all your help.

cs.set(Calendar.MILLISECOND,0);

Thanks again,
0
 
LVL 92

Expert Comment

by:objects
ID: 12324395
good to hear you got it resolved :)
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question