- java.lang.Object
-
- java.nio.file.attribute.FileTime
-
- All Implemented Interfaces:
- Comparable<FileTime>
public final class FileTime extends Object implements Comparable<FileTime>
-
-
Method Summary
Methods Modifier and Type Method and Description int
compareTo(FileTime other)
Compares the value of twoFileTime
objects for order.boolean
equals(Object obj)
Tests thisFileTime
for equality with the given object.static FileTime
from(long value, TimeUnit unit)
Returns aFileTime
representing a value at the given unit of granularity.static FileTime
fromMillis(long value)
Returns aFileTime
representing the given value in milliseconds.int
hashCode()
Computes a hash code for this file time.long
to(TimeUnit unit)
Returns the value at the given unit of granularity.long
toMillis()
Returns the value in milliseconds.String
toString()
Returns the string representation of thisFileTime
.
-
-
-
Method Detail
-
from
public static FileTime from(long value, TimeUnit unit)
Returns aFileTime
representing a value at the given unit of granularity.- Parameters:
value
- the value since the epoch (1970-01-01T00:00:00Z); can be negativeunit
- the unit of granularity to interpret the value- Returns:
- a
FileTime
representing the given value
-
fromMillis
public static FileTime fromMillis(long value)
Returns aFileTime
representing the given value in milliseconds.- Parameters:
value
- the value, in milliseconds, since the epoch (1970-01-01T00:00:00Z); can be negative- Returns:
- a
FileTime
representing the given value
-
to
public long to(TimeUnit unit)
Returns the value at the given unit of granularity.Conversion from a coarser granularity that would numerically overflow saturate to
Long.MIN_VALUE
if negative orLong.MAX_VALUE
if 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
-
toMillis
public long toMillis()
Returns the value in milliseconds.Conversion from a coarser granularity that would numerically overflow saturate to
Long.MIN_VALUE
if negative orLong.MAX_VALUE
if positive.- Returns:
- the value in milliseconds, since the epoch (1970-01-01T00:00:00Z)
-
equals
public boolean equals(Object obj)
Tests thisFileTime
for equality with the given object.The result is
true
if and only if the argument is notnull
and is aFileTime
that represents the same time. This method satisfies the general contract of theObject.equals
method.- Overrides:
equals
in classObject
- Parameters:
obj
- the object to compare with- Returns:
true
if, and only if, the given object is aFileTime
that represents the same time- See Also:
Object.hashCode()
,HashMap
-
hashCode
public 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.- Overrides:
hashCode
in classObject
- Returns:
- the hash-code value
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
compareTo
public int compareTo(FileTime other)
Compares the value of twoFileTime
objects for order.- Specified by:
compareTo
in interfaceComparable<FileTime>
- Parameters:
other
- the otherFileTime
to be compared- Returns:
0
if thisFileTime
is equal toother
, a value less than 0 if thisFileTime
represents a time that is beforeother
, and a value greater than 0 if thisFileTime
represents a time that is afterother
-
toString
public String toString()
Returns the string representation of thisFileTime
. The string is returned in the ISO 8601 format:YYYY-MM-DDThh:mm:ss[.s+]Z
where "[.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
FileTime
is 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
".
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
26/11/2024 00:16:24 Cette version de la page est en cache (à la date du 26/11/2024 00:16:24) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 11/06/2005, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/nio/file/attribute/filetime.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.