Example usage for java.time.temporal TemporalAmount get

List of usage examples for java.time.temporal TemporalAmount get

Introduction

In this page you can find the example usage for java.time.temporal TemporalAmount get.

Prototype

long get(TemporalUnit unit);

Source Link

Document

Returns the value of the requested unit.

Usage

From source file:io.coala.time.TimeSpan.java

/**
 * {@link TimeSpan} static factory method
 * /*from  w  w  w  .j  a v a2  s  .co  m*/
 * @param temporal a JSR-310 {@link TemporalAmount}
 */
public static TimeSpan of(final TemporalAmount temporal) {
    return new TimeSpan(
            BigDecimal.valueOf(temporal.get(ChronoUnit.NANOS))
                    .add(BigDecimal.valueOf(temporal.get(ChronoUnit.MILLIS)).multiply(BigDecimal.TEN.pow(6))),
            Units.NANOS);
}