Accessing field called Date and Time in Event Viewer through Java

259 Views Asked by At

I would like to access the field called Date and time from Event Viewer through Java. I managed to get the EventID :

EVENTLOGRECORD record = new EVENTLOGRECORD(pevlr);
                if (record.EventID.shortValue() == 4624) {
                    System.out.println("Successful log in: " + " Event ID: " + record.EventID.shortValue());
                }
                if (record.EventID.shortValue() == 4634) {
                    System.out.println("Successful log out: " + " Event ID: " + record.EventID.shortValue());
                }

And now the next step would be to get the Date and time

If anyone could help i would really appreciate it !

1

There are 1 best solutions below

0
On BEST ANSWER

Meanwhile I figured out how to get the Date and time field. Just used :

long timestamp = record.TimeGenerated.longValue() * 1000;
                    Date d = new Date(timestamp);