I was wondering if anyone had experience using GPS times and the
Java time/date classes and might be able to offer me advice on a problem I am working on.
I have some data that was collected at various times over a period of years. The time values in the data are stored using GPS Satellite Times, which are measured in seconds from epoch January 6, 1980. I want to format these times in user-readable strings, probably using the Java SimpleDateFormat. I’m thinking that this is more than just a adding a simple offset to adjust the times to the Java epoch January 1, 1970 because the GPS times are absolute measures of duration while terrestrial times are adjusted for leap seconds every couple of years.
Searching on the web, I get the impression that the Java classes always assume a fixed 86400 seconds in a day and to not observe leap seconds. Is this correct? If so, then I would think that a simple offset calculation would result in a Java
string formatted for a time 10 to 15 seconds higher than would have been showing on a terrestrial clock when the data was collected.
My plan is to (1) get a table of dates for when leap seconds were observed, (2) use these to adjust the GPS Satellite Times down to the appropriate Java time in milliseconds, (3) use that time value to create a Date object and pass it into SimpleDateFormat.
The downside to this approach is that it will only work until the next leap second occurs and new data arrives. However, the application I’m working on isn’t that critical (no airplanes will fall from the sky). I just want to make it as good as I reasonably can.
Any recommendations?
Thanks in advance.
P.S. Would the new Java 8 date/time classes have any advantage for this application?