Example usage for org.joda.time LocalDateTime withDate

List of usage examples for org.joda.time LocalDateTime withDate

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime withDate.

Prototype

public LocalDateTime withDate(int year, int monthOfYear, int dayOfMonth) 

Source Link

Document

Returns a copy of this datetime with the specified date, retaining the time fields.

Usage

From source file:todolist.ui.controllers.SettingsController.java

/**
 * isWithinWeek// ww w.  j  a  v a2s.c  o m
 * 
 * @param startOfWeek
 * @param endOfWeek
 * @param endTime
 * @return boolean
 */
private boolean isWithinWeek(LocalDateTime startOfWeek, LocalDateTime endOfWeek,
        java.time.LocalDateTime endTime) {

    int millis = 0;
    int seconds = endTime.getSecond();
    int minutes = endTime.getMinute();
    int hours = endTime.getHour();
    int day = endTime.getDayOfMonth();
    int month = endTime.getMonthValue();
    int year = endTime.getYear();

    LocalDateTime endTimeFormatted = new LocalDateTime();
    endTimeFormatted = endTimeFormatted.withDate(year, month, day);
    endTimeFormatted = endTimeFormatted.withTime(hours, minutes, seconds, millis);

    return endTimeFormatted.isAfter(startOfWeek) && endTimeFormatted.isBefore(endOfWeek);
}