Importing Okta System Log data into your database

I’ve created my own polling/importer using the Spring @Scheduled annotation and comparing the latest database record timestamp with the latest Okta-side timestamp. My relevant snippet looks like this:

    // Convert to ISO Date. Okta is very specific about this. Format MUST be ISO
    		// 8601: 2019-11-13T15:38:49.230-06:00[America/Chicago]
    		sinceDate = ZonedDateTime.of(latestRecordDateTime, ZoneId.systemDefault()).toString();

    		String toDate =;

    		// Now get the logs FROM OKTA between the latest record in the database until
    		// now and insert them into the database.
    		LogEventList logEvents = client.getLogs(toDate, sinceDate, null, null, "DESCENDING");

    		// Get the latest date that Okta has recorded of any activity.
    		LocalDateTime latestOktaDateTime =

    		System.out.println("LATEST OKTA INSERT TIME: " + latestOktaDateTime.toLocalTime().toString());
    		System.out.println("LATEST DATABASE INSERT TIME: " + latestRecordDateTime.toLocalTime().toString());

    		// Compare the latest Okta DateTime value to the latest record in the database.
    		// Is it after?
    		boolean isAfter = latestOktaDateTime.isAfter(latestRecordDateTime);

    		if (isAfter) {

    			for (LogEvent item : logEvents) {

    // Import your Okta data into your local database


Anyone have an other implementations I can maybe get ideas from?