Microsecond support in java.time.Duration/Instant?
Kurt Alfred Kluever
kak at google.com
Mon Jan 22 02:58:55 UTC 2018
At Google, we often use microsecond precision for instants/durations
(probably because of historical reasons). Therefore, we have a handful of
static utility functions for creating/converting java.time types and
public static Duration ofMicros(long micros)
public static long toMicros(Duration duration)
public static Instant ofEpochMicros(long micros)
public static long toEpochMicros(Instant instant)
Duration includes APIs for creating/converting to days, hours, minutes,
seconds, millis, and nanos. Instant includes APIs for creating/converting
to seconds and millis. Micros are noticeably absent.
I'm curious how these sets of units were chosen or decided upon? I
understand that the line must be drawn somewhere (or else someone may come
along asking for centisecond support), but I'm curious as to the rational.
More information about the core-libs-dev