date - Java 7 NIO.2 Files.getLastModifiedTime time zone -
i'm writing program needs determine files/directories last modified time. want handle time using joda time, , i'm using java 7 nio.2 class files file last modified time. getlastmodifiedtime() method returns instance of filetime class, has convenient method tomillis(), result pass joda time datetime class constructor:
new datetime(files.getlastmodifiedtime(path).tomillis()); however, have feeling i'm doing wrong, since datetime(long) constructor explicitly mentions datetime instance created default time zone. filetime docs, however, not mention time zone anywhere. looked through filetime code; seems simple, , tostring() method suggests using utc time zone (it creates calendar in utc time zone , sets milliseconds directly).
so, filetime uses utc or local time? correct way convert filetime datetime?
a java millisecond timestamp utc timestamp. it's filetime.tomillis() returns, , datetime constructor expects. same applies other java api methods; e.g. system.currenttimemillis() method, java.util.date constructor, , on.
they work same way. and, indeed, other unix / linux / osx library methods in other programming languages.
the case breaks if configures / sets system clock incorrectly.
Comments
Post a Comment