Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

lastModified date loses milliseconds  RSS feed

 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have copied several folders of files from PC to my Android tablet after having renamed some here and there and now have many duplicates with different names in different folders.  I thought I could use the lastModified date as a way to find duplicates. Unfortunately the dates on the tablet all have 0s in the 3 lower digits meaning the files date/time stamp is only to the nearest second.
Can the full date/time stamp be preserved?  My tablet is a Android Nexus 7 version 6.0

The code that does the search:

A report from my tablet. Note all lasMods end with 000
>>> thisfn=/storage/emulated/0/Norms/SomeTrip/Singapore/Bus_59map.png lastMod=1497120908000
>>> oldVal=/storage/emulated/0/Norms/SomeTrip/Singapore/Bus_29map.png
>>> thisfn=/storage/emulated/0/Norms/SomeTrip/Singapore/Singapore_BBT Guide_updated.pdf lastMod=1497120908000
>>> oldVal=/storage/emulated/0/Norms/SomeTrip/Singapore/Bus_59map.png
>>> thisfn=/storage/emulated/0/Norms/SomeTrip/Singapore/Singapore_Bus29_TransitLink eGuide - Bus Enquiry.html lastMod=1497120908000
>>> oldVal=/storage/emulated/0/Norms/SomeTrip/Singapore/Singapore_BBT Guide_updated.pdf
>>> thisfn=/storage/emulated/0/Norms/SomeTrip/Singapore/The Singapore Tourist Pass.html lastMod=1497120909000
>>> oldVal=/storage/emulated/0/Norms/SomeTrip/Singapore/Singapore_Train System Map.pdf

A report from my PC.  Last 3 digits are not 0s
>>> thisfn=E:\SomeTrip\Singapore\Bus_29map.png lastMod=1497037471401
>>> oldVal=E:\SomeTrip\Ports\Singapore_Bus_29map.png
>>> thisfn=E:\SomeTrip\Singapore\Bus_59map.png lastMod=1497037430526
>>> oldVal=E:\SomeTrip\Ports\Singapore_Bus_59map.png
>>> thisfn=E:\SomeTrip\Singapore\ChangiHotel_BookingConfirmation.pdf lastMod=1500143423501
>>> oldVal=E:\SomeTrip\Printed\ChangiHotel.pdf
>>> thisfn=E:\SomeTrip\Singapore\Singapore_BBT Guide_updated.pdf lastMod=1497037161369
>>> oldVal=E:\SomeTrip\Ports\Singapore_BBT Guide_updated.pdf
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is with the zip program in Win10.  I zipped two files on Win10 system, then unzipped them into local folders and copied the two files into a folder so there were 3 folders with the same 2 files.
I also printed the contents of the Map at the end.  It appears the zip program throws away the low order time bits:
found=4 in ZipDateTests
found=2 in NeverZipped
found=2 in UnZip1
found=2 in UnZip2
>>> thisfn=D:\Testing\ZipDateTests\UnZip2\Bus_29map.png lastMod=1497037472000
>>> oldVal=D:\Testing\ZipDateTests\UnZip1\Bus_29map.png
>>> thisfn=D:\Testing\ZipDateTests\UnZip2\Bus_59map.png lastMod=1497037432000
>>> oldVal=D:\Testing\ZipDateTests\UnZip1\Bus_59map.png
>>> Print of Map.  First elements are for the unzipped files - have full times.
{1497037430526=D:\Testing\ZipDateTests\NeverZipped\Bus_59map.png, 1497037471401=D:\Testing\ZipDateTests\NeverZipped\Bus_29map.png,
>>>> NOTE Zipped/unzipped files have lost low order time
1497037432000=D:\Testing\ZipDateTests\UnZip2\Bus_59map.png,      1497037472000=D:\Testing\ZipDateTests\UnZip2\Bus_29map.png}
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems setting the lastModified date is not possible on an Android tablet: https://issuetracker.google.com/issues/36930892

I just had a pleasant afternoon writing code to unzip a zip file and set the full lastModified date.  All files and folders that were written had the current date/time on them.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a guess: it might depend on the operating system or file system. Not all file systems store file creation / modification times with a millisecond resolution (and if I remember correctly, most Unix-like operating systems such as Linux and Android indeed don't; they store seconds, but not milliseconds).
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that.  I guess there needs to be another way to manage files if the timestamp is  not useful.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!