This repository was archived by the owner on Sep 1, 2022. It is now read-only.
This repository was archived by the owner on Sep 1, 2022. It is now read-only.
Date truncated by cast to long #1355
Open
Description
Using netcdfAll-4.6.16.1 java library.
I've encountered multiple NetCDF files where the date is truncated by a second in DateUnit.makeStandardDateString(double). The implementation in 4.6.16.1 results in a date string with second precision, but I believe the date is only truncated by a millisecond.
i.e. secs = 89999.999999999985 is incorrectly rounded down to 89999999 milliseconds.
see /cdm/core/src/main/java/ucar/nc2/units/DateUnit.java
getDate (line 191)
makeDate (line 213):
return new Date(getDateOrigin().getTime() + (long) (1000 * secs));
Rounding prior to casting should solve the issue. Something like:
return new Date(getDateOrigin().getTime() + (long) Math.Round(1000 * secs));
Metadata
Metadata
Assignees
Labels
No labels