Solved

Using date properties?

Posted on 2004-10-14
11
169 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
  • 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now