Java ZonedDateTime Calculate uaDateTimeFromTime(ZonedDateTime time)

Here you can find the source of uaDateTimeFromTime(ZonedDateTime time)

Description

ua Date Time From Time

License

Apache License

Declaration

static synchronized long uaDateTimeFromTime(ZonedDateTime time) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.time.Instant;

import java.time.ZonedDateTime;

public class Main {
    private static final long UNIX_EPOCH_BIAS_SEC = 11644473600L;

    static synchronized long uaDateTimeFromTime(ZonedDateTime time) {
        Instant i = Instant.from(time);

        /*//  w  w w. j a va 2  s  . c om
         * A DateTime value is encoded as a 64-bit signed integer which
         * represents the number of 100 nanosecond intervals since January 1,
         * 1601 (UTC).
         */
        long seconds = i.getEpochSecond();
        int nanoOfSecond = i.getNano();
        long value = (UNIX_EPOCH_BIAS_SEC + seconds) * 10000000L
                + nanoOfSecond / 100L;
        return value;
    }
}

Related

  1. toEpochMillSeconds(ZonedDateTime time)
  2. toEpochTime(ZonedDateTime input)
  3. toLocalDateString(ZonedDateTime zonedDateTime)
  4. toUTCZonedDateTime(String dateString)
  5. toZeroMSN(ZonedDateTime dateTime)
  6. Youngest(ZonedDateTime ZDT1, ZonedDateTime ZDT2)
  7. zoneDateTime2long(final ZonedDateTime zdt)