- All Implemented Interfaces:
- Comparable<FileTime>
modified,
 accessed,
 or created.
 Instances of this class are immutable.
- Since:
- 1.7
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionintCompares the value of twoFileTimeobjects for order.booleanTests thisFileTimefor equality with the given object.static FileTimeReturns aFileTimerepresenting a value at the given unit of granularity.static FileTimeReturns aFileTimerepresenting the same point of time value on the time-line as the providedInstantobject.static FileTimefromMillis(long value) Returns aFileTimerepresenting the given value in milliseconds.inthashCode()Computes a hash code for this file time.longReturns the value at the given unit of granularity.Converts thisFileTimeobject to anInstant.longtoMillis()Returns the value in milliseconds.toString()Returns the string representation of thisFileTime.
- 
Method Details- 
fromReturns aFileTimerepresenting a value at the given unit of granularity.- Parameters:
- value- the value since the epoch (1970-01-01T00:00:00Z); can be negative
- unit- the unit of granularity to interpret the value
- Returns:
- a FileTimerepresenting the given value
 
- 
fromMillisReturns aFileTimerepresenting the given value in milliseconds.- Parameters:
- value- the value, in milliseconds, since the epoch (1970-01-01T00:00:00Z); can be negative
- Returns:
- a FileTimerepresenting the given value
 
- 
fromReturns aFileTimerepresenting the same point of time value on the time-line as the providedInstantobject.- Parameters:
- instant- the instant to convert
- Returns:
- a FileTimerepresenting the same point on the time-line as the provided instant
- Since:
- 1.8
 
- 
toReturns the value at the given unit of granularity.Conversion from a coarser granularity that would numerically overflow saturate to Long.MIN_VALUEif negative orLong.MAX_VALUEif positive.- Parameters:
- unit- the unit of granularity for the return value
- Returns:
- value in the given unit of granularity, since the epoch since the epoch (1970-01-01T00:00:00Z); can be negative
 
- 
toMillispublic long toMillis()Returns the value in milliseconds.Conversion from a coarser granularity that would numerically overflow saturate to Long.MIN_VALUEif negative orLong.MAX_VALUEif positive.- Returns:
- the value in milliseconds, since the epoch (1970-01-01T00:00:00Z)
 
- 
toInstantConverts thisFileTimeobject to anInstant.The conversion creates an Instantthat represents the same point on the time-line as thisFileTime.FileTimecan store points on the time-line further in the future and further in the past thanInstant. Conversion from such further time points saturates toInstant.MINif earlier thanInstant.MINorInstant.MAXif later thanInstant.MAX.- Returns:
- an instant representing the same point on the time-line as
          this FileTimeobject
- Since:
- 1.8
 
- 
equalsTests thisFileTimefor equality with the given object.The result is trueif and only if the argument is notnulland is aFileTimethat represents the same time. This method satisfies the general contract of theObject.equalsmethod.
- 
hashCodepublic int hashCode()Computes a hash code for this file time.The hash code is based upon the value represented, and satisfies the general contract of the Object.hashCode()method.
- 
compareToCompares the value of twoFileTimeobjects for order.- Specified by:
- compareToin interface- Comparable<FileTime>
- Parameters:
- other- the other- FileTimeto be compared
- Returns:
- 0if this- FileTimeis equal to- other, a value less than 0 if this- FileTimerepresents a time that is before- other, and a value greater than 0 if this- FileTimerepresents a time that is after- other
 
- 
toStringReturns the string representation of thisFileTime. The string is returned in the ISO 8601 format:YYYY-MM-DDThh:mm:ss[.s+]Zwhere "[.s+]" represents a dot followed by one of more digits for the decimal fraction of a second. It is only present when the decimal fraction of a second is not zero. For example,FileTime.fromMillis(1234567890000L).toString()yields"2009-02-13T23:31:30Z", andFileTime.fromMillis(1234567890123L).toString()yields"2009-02-13T23:31:30.123Z".A FileTimeis primarily intended to represent the value of a file's time stamp. Where used to represent extreme values, where the year is less than "0001" or greater than "9999" then this method deviates from ISO 8601 in the same manner as the XML Schema language. That is, the year may be expanded to more than four digits and may be negative-signed. If more than four digits then leading zeros are not present. The year before "0001" is "-0001".
 
-