public final class FileTime extends Object implements Comparable<FileTime>
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(FileTime other)
比较两个
FileTime对象的价值。
|
boolean |
equals(Object obj)
测试此
FileTime与给定对象的相等性。
|
static FileTime |
from(Instant instant)
返回一个
FileTime表示与提供的
Instant对象相同的时间点值。
|
static FileTime |
from(long value, TimeUnit unit)
返回一个
FileTime ,表示给定的粒度单位的值。
|
static FileTime |
fromMillis(long value)
返回一个
FileTime以
FileTime单位表示给定值。
|
int |
hashCode()
计算此文件时间的哈希码。
|
long |
to(TimeUnit unit)
返回给定的粒度单位的值。
|
Instant |
toInstant()
将此
FileTime对象转换为
Instant 。
|
long |
toMillis()
返回以毫秒为单位的值。
|
String |
toString()
返回此
FileTime的字符串表示
FileTime 。
|
public static FileTime from(long value, TimeUnit unit)
FileTime ,表示给定的粒度单位的值。
value - value的价值(1970-01-01T00:00:00Z);
可以是负数
unit - 解释价值的粒度单位
FileTime代表给定的值
public static FileTime fromMillis(long value)
FileTime给定值(以毫秒为单位)的FileTime。
value - 自纪元(1970-01-01T00:00:00Z)以来的值(以毫秒为单位);
可以是负数
FileTime给定值的
FileTime
public static FileTime from(Instant instant)
FileTime表示与提供的
Instant对象相同的时间点值。
instant - 即时转换
FileTime代表在提供的时刻的时间线上的同一点
public long to(TimeUnit unit)
如果为负, Long.MAX_VALUE数值溢出饱和的粗粒度转换为Long.MIN_VALUE ,否则为Long.MAX_VALUE 。
unit - 返回值的粒度单位
public long toMillis()
如果为负, Long.MAX_VALUE数值溢出饱和的较粗粒度转换为Long.MIN_VALUE ,否则为Long.MAX_VALUE 。
public Instant toInstant()
FileTime对象转换为Instant 。
转换创建Instant表示基于时间线,因为这同一点FileTime 。
FileTime可以在未来进一步存储时间点上的点数,并且在过去比Instant进一步。 如果早于Instant.MIN或Instant.MAX如果晚于Instant.MAX则从这样的进一步时间点的转换将饱和为Instant.MAX 。
FileTime对象相同的点
public boolean equals(Object obj)
FileTime与给定对象的相等性。
其结果是true当且仅当参数不是null ,是一个FileTime表示同一时间。 这种方法满足的总承包Object.equals方法。
equals在
Object
obj - 要比较的对象
true ,当且仅当给定的对象是
FileTime表示同时
Object.hashCode() , HashMap
public int hashCode()
哈希代码是基于代表的值,并满足Object.hashCode()方法的一般合同。
hashCode在
Object
Object.equals(java.lang.Object) ,
System.identityHashCode(java.lang.Object)
public int compareTo(FileTime other)
FileTime对象的价值。
compareTo在接口
Comparable<FileTime>
other - 其他
FileTime待比较
0如果此
FileTime等于
other ,一个小于0的值,如果这
FileTime表示时间即前
other ,和大于0的值,如果这个
FileTime表示时间,该时间之后
other
public String toString()
FileTime的字符串表示FileTime 。
字符串以ISO 8601格式返回:
YYYY-MM-DDThh:mm:ss[.s+]Z
其中“ [.s+] ”表示一个点,后面是一秒数的小数位数。
只有当秒的小数部分不为零时才存在。
例如, FileTime.fromMillis(1234567890000L).toString()产生"2009-02-13T23:31:30Z" ,而FileTime.fromMillis(1234567890123L).toString()产生"2009-02-13T23:31:30.123Z" 。
A FileTime主要用于表示文件时间戳的值。 如果用于表示极值 ,如果年份小于“ 0001 ”或大于“ 9999 ”,则该方法与XML Schema language相同的方式偏离ISO 8601。 也就是说,年份可能会扩大到四位以上,可能是负号。 如果超过四位数,则前导零不存在。 前一年“ 0001 ”是“ -0001 ”。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.