Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java File.lastModified returned value changes if timezone changes?

Tags:

java

file

android

Is the function lastModified from class File returning allways the same value even if the current device time is updated or even if the user changes the device timezone?

like image 340
The Matrix Avatar asked Nov 16 '25 08:11

The Matrix


2 Answers

File.lastModified corresponds to the last time the file that File points to was updated, and it's expressed in UTC milliseconds since the Epoch (1-1-1970). So, no, it does not change unless you modify the file.

like image 116
Tassos Bassoukos Avatar answered Nov 18 '25 23:11

Tassos Bassoukos


Generally File.lastmodified is a static value (that can be updated, if you 'modify the file', obviously)

However, it is technically possible for 'root' on a linux system to modify the value https://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file (yes, I know... not 'Android', but Android runs the linux kernel and can probably do the same thing. if the person has rooted their phone.)

So it is 'technically' possible to change that value, but 'realistically' it won't change unless the file is changed/modified/etc.

like image 24
mawalker Avatar answered Nov 18 '25 23:11

mawalker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!