Search code examples
javaandroidlast-modifiedmodified-date

Why is Java (Android?) setting my file's last modified date to tomorrow?


I'm creating files in my Android application using:

FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
fos.write(data);
fos.flush();
fos.close();

Then later I'm trying to do some cleanup, so I'm comparing the last modified date to some threshold value, but the comparison is showing that the file's last modified date is tomorrow sometime. Keep in mind, when I say tomorrow, that is relative to today (the file modification date)... whichever day this may be that you're reading this.

So basically, if I create the file today, and check the file's last modification date, it says it was last modified tomorrow.

Is this something Java is doing, or Android, or something I'm doing?


Solution

  • What does your test device/emulator show the current date and time as? It sounds like they're just set incorrectly.

    Is the time zone on the device set to something other than your local time for instance?