Java LocalDateTime Calculate secondsBetween(LocalDateTime date1, LocalDateTime date2)

Here you can find the source of secondsBetween(LocalDateTime date1, LocalDateTime date2)

Description

Calculate the time between two dates, in seconds

License

Open Source License

Parameter

Parameter Description
date1 The first date
date2 The second date

Return

The number of seconds between the dates

Declaration

public static long secondsBetween(LocalDateTime date1, LocalDateTime date2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.time.LocalDateTime;

import java.time.temporal.ChronoUnit;

public class Main {
    /**/*from   w w  w.j  a  va 2 s .co m*/
     * Calculate the time between two dates, in seconds
     * @param date1 The first date
     * @param date2 The second date
     * @return The number of seconds between the dates
     */
    public static long secondsBetween(LocalDateTime date1, LocalDateTime date2) {
        return ChronoUnit.SECONDS.between(date1, date2);
    }
}

Related

  1. parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time)
  2. parseTimeStamp(LocalDateTime actualDate, LocalDateTime checkedDate, boolean isDateFrom)
  3. printDateTime(LocalDateTime dateTime)
  4. relativeDateTime(final LocalDateTime contextDate, final String str, final boolean add)
  5. safeCreateFromValue(LocalDateTime datetime, int year, int month, int day, int hour, int minute, int second)
  6. setTime(LocalDateTime source, String time)
  7. shiftDateTime(String timex, LocalDateTime reference, boolean future)
  8. shouldSend(Optional emailSentOpt, int timeToWait)
  9. sleepUntil(LocalDateTime next)