0

I have 5 text files that have computer clock in and clock out times for each employee.

The first column of each file has an identification number for each employee, and the remaining 10 columns have clock in and clock out times for the week (clock in times are in columns 2,4,6,8 and 10 and clock out times are in columns 3,5,7,9 and 11).

The dates are in EEE MM/dd/yyyy hh:mm a format.

I need to subtract each clock in column from each clock out column next to it to get the total hours worked for that particular day (for example, column 3 has the clock out time for 11/7 and column 2 has the clock in time for the same date...so column 2 must be subtracted from column 3).

I need a java program that can be fed all these files, read the dates and subtract them, and write the results to a new file with the ID numbers.

I thought of maybe somehow converting the text files into one CSV file, putting them into a two dimensional array, and then subtracting one array column from the other but I'm not sure if this would work (and I'm not sure how to do this).

I probably would have to use an arraylist since the number of rows of clock-in/out times could vary.

I really wanted to avoid lumping all the data into a single text file and having to move array or arraylist references endlessly to the right to subtract the dates.

Any help you can give me would be much appreciated.

Thank you.

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
iac
  • 9
  • 2
  • http://stackoverflow.com/questions/2003521/find-total-hours-between-two-dates – Lefteris008 Nov 11 '16 at 08:48
  • I don't see any question here. Just "I need to make a program". Well, start, think, read documentation, experiment, try again, and if you have a concrete question, ask. – JB Nizet Nov 11 '16 at 08:54

1 Answers1

0

If the file is tab delimited you might be able to use something like described in the accepted answer here to read the data into arraylists: Read a file separated by tab and put the words in an ArrayList

Community
  • 1
  • 1
Robert M.
  • 575
  • 5
  • 17