Code with Finding: |
class PassportService {
/**
* Reads the date of birth of the passport holder
*
* @return the date of birth
*
* @throws IOException if something goes wrong
* @throws NumberFormatException if something goes wrong
*/
public Date readDateOfBirth() throws IOException, NumberFormatException {
byte[] fileData = readMRZ();
DataInputStream in = new DataInputStream(new ByteArrayInputStream(fileData));
in.skip(2);
in.skip(3);
in.skip(39);
in.skip(9);
in.skip(1);
in.skip(3);
byte[] data = new byte[6];
in.readFully(data);
String dateString = new String(data).trim();
System.out.println("DEBUG: " + dateString);
return makeDate(1900, dateString);
}
}
|