Java LocalDateTime Calculate balanceStartAndEndDateTime(LocalDateTime startDateTime, LocalDateTime endDateTime)

Here you can find the source of balanceStartAndEndDateTime(LocalDateTime startDateTime, LocalDateTime endDateTime)

Description

Takes two LocalDateTime and balances by ensuring that the latter DateTime is gaurenteed to be later than the former DateTime

License

Open Source License

Parameter

Parameter Description
startDateTime a parameter
endDateTime a parameter

Return

endDateTime that is now balanced

Declaration

public static LocalDateTime balanceStartAndEndDateTime(LocalDateTime startDateTime, LocalDateTime endDateTime) 

Method Source Code


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

import java.time.LocalDateTime;

public class Main {
    /**/*from w  ww  .  jav a 2  s  .  com*/
     * Takes two LocalDateTime and balances by ensuring that the latter DateTime is gaurenteed to be later
     * than the former DateTime
     * @param startDateTime
     * @param endDateTime
     * @return endDateTime that is now balanced
     */
    public static LocalDateTime balanceStartAndEndDateTime(LocalDateTime startDateTime, LocalDateTime endDateTime) {
        LocalDateTime newEndDateTime = endDateTime;
        while (startDateTime.compareTo(newEndDateTime) >= 1) {
            newEndDateTime = newEndDateTime.plusDays(1);
        }
        return newEndDateTime;
    }
}

Related

  1. add(final LocalDateTime original, final int years, final int months, final int days, final int hours, final int minutes)
  2. addHeureMinute(final LocalDateTime time, final int heures, final int minutes)
  3. areDatesOneMonthApart(LocalDateTime start, LocalDateTime end)
  4. atMidnight(LocalDateTime value)
  5. before(LocalDateTime time1, LocalDateTime time2)
  6. calcNextDayOfWeekFromLDT(LocalDateTime ldt, DayOfWeek dow)
  7. ceilDate(LocalDateTime dateTime)
  8. checkIfTimeExist(LocalDateTime date)