Example usage for org.joda.time DateTime withField

List of usage examples for org.joda.time DateTime withField

Introduction

In this page you can find the example usage for org.joda.time DateTime withField.

Prototype

public DateTime withField(DateTimeFieldType fieldType, int value) 

Source Link

Document

Returns a copy of this datetime with the specified field set to a new value.

Usage

From source file:com.facebook.util.TimeIntervalType.java

License:Apache License

protected DateTime clearField(DateTime value) {
    return value.withField(fieldType, fieldType.getField(value.getChronology()).getMinimumValue());
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.RoomSiteComponentServiceByExecutionPeriodID.java

License:Open Source License

private static Calendar findMonday(final Calendar someDay) {
    final DateTime dateTime = new DateTime(someDay.getTimeInMillis());
    return dateTime.withField(DateTimeFieldType.dayOfWeek(), 1).toCalendar(null);
}

From source file:net.sourceforge.fenixedu.domain.Attends.java

License:Open Source License

public Interval getWeeklyWorkLoadInterval() {
    final DateTime beginningOfSemester = new DateTime(getBegginingOfLessonPeriod());
    final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
    final DateTime endOfSemester = new DateTime(getEndOfExamsPeriod());
    final DateTime nextLastMonday = endOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1).plusWeeks(1);
    return new Interval(firstMonday, nextLastMonday);
}

From source file:net.sourceforge.fenixedu.domain.ExecutionCourse.java

License:Open Source License

public Interval getInterval() {
    final ExecutionSemester executionSemester = getExecutionPeriod();
    final DateTime beginningOfSemester = new DateTime(executionSemester.getBeginDateYearMonthDay());
    final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
    final DateTime endOfSemester = new DateTime(executionSemester.getEndDateYearMonthDay());
    final DateTime nextLastMonday = endOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1).plusWeeks(1);
    return new Interval(firstMonday, nextLastMonday);
}

From source file:net.sourceforge.fenixedu.domain.student.WeeklyWorkLoad.java

License:Open Source License

public Interval getInterval() {
    final DateTime beginningOfSemester = new DateTime(getAttends().getBegginingOfLessonPeriod());
    final DateTime firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1);
    final DateTime start = firstMonday.withFieldAdded(DurationFieldType.weeks(), getWeekOffset().intValue());
    final DateTime end = start.plusWeeks(1);
    return new Interval(start, end);
}

From source file:pt.utl.ist.codeGenerator.database.EvaluationRoomManager.java

License:Open Source License

public EvaluationRoomManager(final DateTime startDateTime, final DateTime endDateTime,
        final int evaluationDurationInMinutes, Set<Space> oldRooms) {
    this.startDateTime = startDateTime.withField(DateTimeFieldType.hourOfDay(), 8);
    this.endDateTime = endDateTime.withField(DateTimeFieldType.hourOfDay(), 20);
    this.nextDateTime = startDateTime;
    this.evaluationDurationInMinutes = evaluationDurationInMinutes;
    addAll(oldRooms);/*from   w  w w  .  j a  v  a 2  s. c  o  m*/
}

From source file:utils.JodaDateUtil.java

License:Apache License

/**
 * Force update HH:mm:ss -> 23:59:59/*from w ww. java2s . c o  m*/
 */
public static Date lastSecondOfDay(Date date) {
    if (date == null) {
        return null;
    }
    DateTime dateTime = new DateTime(date);
    return dateTime.withField(DateTimeFieldType.hourOfDay(), 23).withField(DateTimeFieldType.minuteOfHour(), 59)
            .withField(DateTimeFieldType.secondOfMinute(), 59).toDate();
}