Java LocalDateTime Calculate last(LocalDateTime from, int dayOfWeek)

Here you can find the source of last(LocalDateTime from, int dayOfWeek)

Description

last

License

Open Source License

Declaration

public static LocalDateTime last(LocalDateTime from, int dayOfWeek) 

Method Source Code


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

import java.time.LocalDateTime;

public class Main {
    public static LocalDateTime last(LocalDateTime from, int dayOfWeek) {
        int start = from.getDayOfWeek().getValue();

        if (start == 0) {
            start = 7;/*from  w ww.  ja va 2 s . c  o m*/
        }

        if (dayOfWeek == 0) {
            dayOfWeek = 7;
        }

        return from.plusDays(dayOfWeek - start - 7);
    }
}

Related

  1. isBefore(LocalDateTime dateTime1, LocalDateTime dateTime2)
  2. isOverdue(LocalDateTime dueTime)
  3. isToday(LocalDateTime dateTime)
  4. isTodayOrYesterday(LocalDateTime date)
  5. isWithin(LocalDateTime start, LocalDateTime end)
  6. localDateTime2LocalDate(LocalDateTime localDateTime)
  7. ms2LocalDateTime(final long ms)
  8. oldDateToISO8601LocalDateTime(Date nextColumnDate)
  9. parseStringToLocalDateTimeWithSpecifiedTime(String strDate, String time)