I'm creating temporary directories with
Files.createTempDirectory(String.format("project-it-screenshots-%d",
System.currentTimeMillis())).toFile();
an I assumed that the long
s returned by System.currentTimeMillis()
all have the same length because two return values with different length have to come from different centuries. After invoking the method multiple times per day I ended up with
project-it-screenshots-15343380422205011345585140911467
project-it-screenshots-15343381444485756307954062111474
project-it-screenshots-15343386111604255833362898885857
project-it-screenshots-15343388402055473274775132302475
project-it-screenshots-1534338974370463603854456850155
project-it-screenshots-15343390449093279576023746896269
project-it-screenshots-15343398036346426501075034038757
project-it-screenshots-15343399888498609875231360701639
project-it-screenshots-15343401211515574289310135012571
project-it-screenshots-15343405563586337945661543042110
project-it-screenshots-15343419027757787065954653813302
project-it-screenshots-15343425353682119990056938907868
project-it-screenshots-15343429571018010152043055630277
project-it-screenshots-15343431608662744493593200651167
project-it-screenshots-15343436122094379676346949668973
project-it-screenshots-15343442103124076542522856351947
project-it-screenshots-15343539846818150078805796257638
project-it-screenshots-15343555678106536264262565060437
project-it-screenshots-15343809068582300780873443756155
project-it-screenshots-15344378068483088975615680511653
project-it-screenshots-15344421866441533761733546877922
where 1534338974370463603854456850155
is one digit shorter than the others. This seems to be unrelated to stripping of leading 0
s because there're none and to trailing 0
s because some numbers with the larger length have them and others don't.
I'm searching for an explanation, not a workaround (I'll use a formatted date which can be sorted or add 0
padding to the number with String.format
which only changes the timestamp slightly).
I'm using OpenJDK 8 on Ubuntu 18.04.