Get time in seconds since epoch (UTC) – Java 8

import java.util.*;
import java.lang.*;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;

public class MainClass
	public static void main (String[] args) throws java.lang.Exception
		long now =;

Parsing Uber bills

It’s the time of the year I have to generate expense reports and I need three details for the invoices. First the invoice number, second the invoice date and the third gross amount paid.

Now the Uber invoice is pdf as shown in figure below:2017-07-27 12_44_30-Clipboard

As opening PDF files and getting data from it manually was kind of painful, so I wrote a python script for my help. Here it is:

import PyPDF2
import os

dirPath = 'C:/path_to_directory_containing_invoices/'
fileList = os.listdir()

for fileName in fileList:

    f = open(dirPath+fileName, 'rb')
    reader = PyPDF2.PdfFileReader(f)
    contents = reader.getPage(0).extractText().split('\n')
    invoice_number = ""
    invoice_date = ""
    gross_amount = ""

    for i in range(len(contents)):
        if contents[i].find("Invoice Number") != -1:
            invoice_number = contents[i].split(': ')[1]
        if contents[i].find("Invoice Date") != -1:
            invoice_date = contents[i].split(': ')[1]
        if contents[i].find("Gross Amount") != -1:
            gross_amount = contents[i+1].split(' ')[0]

    print(invoice_number + ", " + invoice_date + ", " + gross_amount)

It uses PyPDF library. This link tells you how to install it and use it.