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

file timestamp  RSS feed

 
kaz juback
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I just wrote a small code to check the file.lastmodified() value for a batch of 130 files.
The code is quite simple and looks like this


The problem is that the output of this program is different on another system that one of my friends ran it on.His output for the same batch of files shows 1159211862135 as output while mine shows 1159211862000
Im using JDK 5.0 and he's using JDK 1.4.2
Can you tell me why my system is showing values like 1159211862000,1159211860000 etc while his system prints out the last 2 digits differently.

Thanks
K
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kaz juback:
...Im using JDK 5.0 and he's using JDK 1.4.2...

Hmmm... This looks similar to Bug 4504473. Depending on how you're testing it, might this account for the behavior?

Just to confirm, the 5.0 version is showing zeros as the last 3 digits? But the 1.4 version is showing non-zeros? (I just tested your code using 1.5.0_06 on Windows XP, and got non-zeros.)
[ March 26, 2007: Message edited by: marc weber ]
 
kaz juback
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc

Thanks for the reply

Yes the code on java 5.0 shows 1174931368000 while the one on JDK 1.4.2 shows something like 1174931368257.
Both systems are Windows XP.
The way i tested was that i moved these files from an AIX system onto my system and then i tested the file.lastmodified method on each of them.
The interesting thing is when i modify a file on my system and then check the lastmodified value it does not show 0's as the last 3 digits but accurately prints the last 3 digits as the systemtime in milliseconds.
This behavious is really weird.
My friend is gone for the day but tommorow i intend to test this in more detail.
Please let me know if you have any suggestions.

Thanks for your help and time.
Kaz
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by marc weber:
...I just tested your code using 1.5.0_06 on Windows XP, and got non-zeros...

This is interesting. I'm now home using a Mac (OS 10.4.9 with Java 1.5.0_07), and I get 3 zeros at the end of all my times. According to Wikipedia - Unix Timestamp...
The standard Unix time_t (data type representing a point in time) is a signed integer data type, traditionally of 32 bits (but see below), directly encoding the Unix time number as described in the preceding section. Being integer means that it has a resolution of one second; many Unix applications therefore handle time only to that resolution.

So it seems reasonable (I think) that files transfered from an AIX (Unix) system would not show milliseconds until they are re-saved on your XP system. I gather from a previous post that you have Java 1.4.2 running on the AIX box. I'm guessing that lastModifed would show zero milliseconds on that machine (even with Java 1.4.2). The curious thing is why milliseconds are displayed on your friend's XP system.
[ March 26, 2007: Message edited by: marc weber ]
 
kaz juback
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc

I did some testing today with my friend.
You are right about the unix systems.For some reason the last 3 digits of all the timestamps are rounded of to zeros.
The only really strange thing is my friend was able to print the actual value while i couldnt.He's on Windows 2000 and not XP as i had mentioned earlier.

Thanks a lot for your help.I really appreciate it.
Kaz
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kaz juback:
... The only really strange thing is my friend was able to print the actual value while i couldnt.He's on Windows 2000 and not XP as i had mentioned earlier...

Yeah, that's the odd part. I'm not convinced that these last 3 digits represent "actual" values. If the milliseconds are not part of the Unix time stamp, then where are these non-zero values coming from? Do they really mean anything? Or are they artifacts of some kind?

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!