Java LocalDateTime to getMillis(LocalDateTime time)

Here you can find the source of getMillis(LocalDateTime time)

Description

get Millis

License

LGPL

Declaration

public static long getMillis(LocalDateTime time) 

Method Source Code


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

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.chrono.ChronoZonedDateTime;

public class Main {
    public static long getMillis(LocalDateTime time) {
        if (time == null) {
            return 0;
        }/*from   w  w w  . j a  v a2 s .  c  om*/
        Instant instant = ((ChronoZonedDateTime) time.atZone(ZoneId.systemDefault())).toInstant();
        return instant.toEpochMilli();
    }
}

Related

  1. getDelayUntil(final LocalDateTime ldt)
  2. getDifference(LocalDateTime sourceTime, LocalDateTime targetTime)
  3. getDurationInMillis(LocalDateTime from, LocalDateTime to)
  4. getDurationString(LocalDateTime start, LocalDateTime end, ChronoUnit unit)
  5. getHoursElapsed(LocalDateTime fromDate)
  6. getMinuteOfDay(LocalDateTime ldt)
  7. getSecondsSinceJavaEpoch(LocalDateTime localDateTime)
  8. localDateTimeToDate(LocalDateTime ldt)
  9. localDateTimeToEpochMillis(TemporalAccessor temporal)