Java Instant Create convertDotNetTicksToInstant(long dotNetTicks)

Here you can find the source of convertDotNetTicksToInstant(long dotNetTicks)

Description

convert Dot Net Ticks To Instant

License

Open Source License

Declaration

public static Instant convertDotNetTicksToInstant(long dotNetTicks) 

Method Source Code

//package com.java2s;
/*/*from   ww w  . java  2  s  .  com*/
 * Copyright (c) Microsoft. All rights reserved.
 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
 */

import java.time.Instant;

public class Main {
    private static final long EPOCHINDOTNETTICKS = 621355968000000000l;

    public static Instant convertDotNetTicksToInstant(long dotNetTicks) {
        long ticksFromEpoch = dotNetTicks - EPOCHINDOTNETTICKS;
        long millisecondsFromEpoch = ticksFromEpoch / 10000;
        long fractionTicks = ticksFromEpoch % 10000;
        return Instant.ofEpochMilli(millisecondsFromEpoch).plusNanos(fractionTicks * 100);
    }
}

Related

  1. deserializeToInstant(String date)
  2. deserializeToInstant(String date)
  3. end(String msg, long amount, Instant start)
  4. getEarliestInstant()