Originally posted by Amy Howard:
It seems that I need two steps for this problem.
(1) get all dates (string type) between d1 and d2.
(2) store dates in vector or array (which one is better?)
Can you please provide me your solution with code in details?
Thanks for your help!!!
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
This is abetter solution for your particular problem but you should use the Calendar class since it has the convenience comparison methods, before and after.Originally posted by Layne Lund:
First, I would create two Date objects to represent the range. Then read an error from the log file into a String and convert it to a Date object as well. I think Date provides some comparison methods so you can easily test if the Date from the log file is between the Dates that represent your range. For the details, you should check the API docs.
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Originally posted by Amy Howard:
d1 = new GregorianCalendar(dt1); //error
d2 = new GregorianCalendar(dt2); //error
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Originally posted by Thomas Paul:
It seems to me that it would be faster to just read in the files and scan the lines. The dates are always in a fixed position so it shouldn't be a big deal. I don't think you need a regex for this at all.
Originally posted by Jason Menard:
Either way, it's about damn time Java incorporated regexes into the JDK.
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
"I'm not back." - Bill Harding, Twister
Originally posted by Jim Yingst:
Cool, eh? Let's try this:
Hey Thomas - it's about damn time Java incorporated a foreach keyword and parameterized types into the JDK!
Waiting patiently...![]()
Originally posted by Jim Yingst:
To be fair, I interpreted Jason's comment as "I'm glad regexes were finally incorporated in 1.4, but they were long overdue." Could be mistaken though.
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Originally posted by Thomas Paul:
I did too but I couldn't resist mis-understanding him.![]()
"I'm not back." - Bill Harding, Twister
Originally posted by Jim Yingst:
Yes, dammit. I'm already making plans for foreach; I want it now.![]()
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
"I'm not back." - Bill Harding, Twister
For all that, I'm not even sure this expression will be any faster than a solution based on Jason's pseudocode. And this is certainly harder to program. I'd implement Jason's solution first (it's halfway done already) and see how fast it is. Then try running another search with a statically-created pattern like the one above, to see how fast it is.
"I'm not back." - Bill Harding, Twister
I don't even know how to spell CIA. But this tiny ad does:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|