Java LocalDateTime to getSecondsSinceJavaEpoch(LocalDateTime localDateTime)

Here you can find the source of getSecondsSinceJavaEpoch(LocalDateTime localDateTime)

Description

get Seconds Since Java Epoch

License

Open Source License

Declaration

private static long getSecondsSinceJavaEpoch(LocalDateTime localDateTime) 

Method Source Code

//package com.java2s;
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.concurrent.TimeUnit;

public class Main {
    private static long getSecondsSinceJavaEpoch(LocalDateTime localDateTime) {
        // Adjust TimeZone Offset:
        OffsetDateTime zdt = localDateTime.atOffset(ZoneOffset.UTC);
        // Get the Epoch Milliseconds:
        long milliseconds = zdt.toInstant().toEpochMilli();
        // Turn into Seconds:
        return TimeUnit.MILLISECONDS.toSeconds(milliseconds);
    }//from www  . j a v  a2s  .  c o m
}

Related

  1. getDurationInMillis(LocalDateTime from, LocalDateTime to)
  2. getDurationString(LocalDateTime start, LocalDateTime end, ChronoUnit unit)
  3. getHoursElapsed(LocalDateTime fromDate)
  4. getMillis(LocalDateTime time)
  5. getMinuteOfDay(LocalDateTime ldt)
  6. localDateTimeToDate(LocalDateTime ldt)
  7. localDateTimeToEpochMillis(TemporalAccessor temporal)
  8. localDateTimeToString(LocalDateTime value)
  9. localDateTimeToTimestamp(LocalDateTime ldt)