常用时间单位换算
所属分类 java
浏览量 1466
秒 毫秒 微秒 纳秒 皮秒
s ms μs ns ps
second
millisecond
microsecond
nanosecond
picosecond
1秒 1000毫秒
1毫秒 1000微秒
1微秒 1000纳秒
1纳秒 1000皮秒
java.util.concurrent.TimeUnit
public enum TimeUnit
NANOSECONDS
MICROSECONDS
MILLISECONDS
SECONDS
MINUTES
HOURS
DAYS
public enum TimeUnit {
NANOSECONDS {
public long toNanos(long d) { return d; }
public long toMicros(long d) { return d/(C1/C0); }
public long toMillis(long d) { return d/(C2/C0); }
public long toSeconds(long d) { return d/(C3/C0); }
public long toMinutes(long d) { return d/(C4/C0); }
public long toHours(long d) { return d/(C5/C0); }
public long toDays(long d) { return d/(C6/C0); }
public long convert(long d, TimeUnit u) { return u.toNanos(d); }
int excessNanos(long d, long m) { return (int)(d - (m*C2)); }
}
static final long C0 = 1L;
static final long C1 = C0 * 1000L;
static final long C2 = C1 * 1000L;
static final long C3 = C2 * 1000L;
static final long C4 = C3 * 60L;
static final long C5 = C4 * 60L;
static final long C6 = C5 * 24L;
System.out.println(TimeUnit.SECONDS.toMillis(1));
System.out.println(TimeUnit.SECONDS.toMicros(1));
System.out.println(TimeUnit.SECONDS.toNanos(1));
1000
1000000
1000000000
上一篇
下一篇
java日志系统转换
log4j无缝迁移到logback
jdk日志无缝迁移到slf4j
slf4j简介
logback初始化过程
logback的内部日志输出