List of usage examples for java.time Instant getNano
public int getNano()
From source file:Main.java
public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.MAX; Instant i = o.toInstant(); System.out.println(i.getNano()); }
From source file:Main.java
public static void main(String[] args) { Instant instant = Instant.parse("2014-12-03T10:15:30.00Z"); System.out.println(instant.getNano()); }
From source file:Main.java
public static void main(String[] args) { Instant now = Instant.now(); System.out.println(now);//w w w .j a v a 2 s. c o m System.out.println(now.getEpochSecond()); System.out.println(now.getNano()); }
From source file:Main.java
public static void main(String[] args) { Instant i1 = Instant.now(); long seconds = i1.getEpochSecond(); System.out.println(seconds);// w ww.j a v a2 s . c o m int nanoSeconds = i1.getNano(); System.out.println(nanoSeconds); }
From source file:Main.java
public static Date toDate(Instant instant) { BigInteger milis = BigInteger.valueOf(instant.getEpochSecond()).multiply(BigInteger.valueOf(1000)); milis = milis.add(BigInteger.valueOf(instant.getNano()).divide(BigInteger.valueOf(1_000_000))); return new Date(milis.longValue()); }
From source file:com.aerospike.delivery.db.aerospike.AerospikeDatabase.java
static long[] instantToLongs(Instant instant) { if (instant == null) return null; return new long[] { instant.getEpochSecond(), instant.getNano() }; }
From source file:org.hyperledger.fabric.sdk.helper.SDKUtil.java
/** * Create a new {@link Timestamp} instance based on the current time * @return timestamp//from ww w.j a v a 2 s. c o m */ public static Timestamp generateTimestamp() { Instant time = Instant.now(); Timestamp timestamp = Timestamp.newBuilder().setSeconds(time.getEpochSecond()).setNanos(time.getNano()) .build(); return timestamp; }
From source file:org.hyperledger.fabric.sdk.helper.Utils.java
/** * Create a new {@link Timestamp} instance based on the current time * * @return timestamp/*from w w w. ja v a 2 s .c om*/ */ public static Timestamp generateTimestamp() { Instant time = Instant.now(); return Timestamp.newBuilder().setSeconds(time.getEpochSecond()).setNanos(time.getNano()).build(); }
From source file:org.hyperledger.fabric.sdk.transaction.ProtoUtils.java
public static Timestamp getCurrentFabricTimestamp() { Instant time = Instant.now(); return Timestamp.newBuilder().setSeconds(time.getEpochSecond()).setNanos(time.getNano()).build(); }
From source file:org.trellisldp.http.impl.HttpUtils.java
/** * Build a hash value suitable for generating an ETag. * @param identifier the resource identifier * @param modified the last modified value * @param prefer a prefer header, may be null * @return a corresponding hash value//from w w w . j a v a 2s. c o m */ public static String buildEtagHash(final String identifier, final Instant modified, final Prefer prefer) { final String sep = "."; final String hash = nonNull(prefer) ? prefer.getInclude().hashCode() + sep + prefer.getOmit().hashCode() : ""; return md5Hex(modified.toEpochMilli() + sep + modified.getNano() + sep + hash + sep + identifier); }