Amdocs

  www.amdocs.com
Work in HR? Unlock Free Profile

Amdocs Release Engineer Interview Question

I interviewed in El Dorado Hills, CA and was asked:
"How would you list all the files newer than yesterday?"
Add Tags [?]
Answer

Part of a Release Engineer Interview Review - one of 233 Amdocs Interview Reviews

Answers & Comments

0
of 0
votes
if files are all inside the arraylist/linked list called 'files' then:

while(files.hasNext())
{
file = files.next();

long fileDate = file.getDateofCreation();
long currentDate = system.getCurrentDate();

long diff = currentDate - fileDate;

long yesterday = currentDate - (24 * 60 * 60 * 1000); //yesterday in milliseconds hrs * min * secs

if ( diff > yesterday)
selectTheFile(file);
else
dicardTheFile(file);

}
- George on Jul 29, 2011
0
of 0
votes
If you are in the directory that has all the files you wanna sort, I believe there's a unix command to use:
find -maxdepth 1 -type f -mtime 1
- Ina on Dec 7, 2012

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.