Example usage for org.joda.time DateTime plusHours

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

Introduction

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

Prototype

public DateTime plusHours(int hours) 

Source Link

Document

Returns a copy of this datetime plus the specified number of hours.

Usage

From source file:kr.debop4j.timeperiod.timerange.HourRangeCollection.java

License:Apache License

/**
 * Gets hours.//www .j ava  2s  . c o m
 *
 * @return the hours
 */
public List<HourRange> getHours() {
    DateTime startHour = Times.trimToMinute(getStart());

    int hourCount = getHourCount();
    List<HourRange> hours = Lists.newArrayListWithCapacity(hourCount);
    for (int h = 0; h < hourCount; h++)
        hours.add(new HourRange(startHour.plusHours(h), getTimeCalendar()));

    return hours;
}

From source file:kr.debop4j.timeperiod.timerange.HourTimeRange.java

License:Apache License

/**
 *  ? ~  ? ??  (Minute) ? ?  ./*  w  w w . j a v  a  2  s  .c  o  m*/
 *
 * @return   ({@link MinuteRange}? 
 */
public List<MinuteRange> getMinutes() {
    DateTime start = getStart();
    ITimeCalendar timeCalendar = getTimeCalendar();
    List<MinuteRange> minutes = Lists.newArrayListWithCapacity(hourCount * TimeSpec.MinutesPerHour);

    for (int h = 0; h < hourCount; h++) {
        for (int m = 0; m < TimeSpec.MinutesPerHour; m++) {
            minutes.add(new MinuteRange(start.plusHours(h).plusMinutes(m), timeCalendar));
        }
    }

    return minutes;
}

From source file:kr.debop4j.timeperiod.timerange.HourTimeRange.java

License:Apache License

private static TimeRange getPeriodOf(int year, int month, int day, int hour, int hourCount) {
    assert hourCount > 0;

    DateTime start = new DateTime(year, month, day, hour, 0, 0);
    DateTime end = start.plusHours(hourCount);

    return new TimeRange(start, end);
}

From source file:kr.debop4j.timeperiod.tools.Times.java

License:Apache License

/**  ?  (hours) ??  */
public static TimeRange getRelativeHourPeriod(DateTime start, int hours) {
    return getTimeRange(start, start.plusHours(hours));
}

From source file:kr.debop4j.timeperiod.tools.Times.java

License:Apache License

/**  ? (Hour)  . */
public static List<ITimePeriod> foreachHours(ITimePeriod period) {
    shouldNotBeNull(period, "period");

    if (isTraceEnabled)
        log.trace("[{}]?  (Hour)  ...", period);

    List<ITimePeriod> hours = Lists.newArrayList();
    if (period.isAnytime())
        return hours;

    assertHasPeriod(period);// ww  w .  j  a  v a  2 s . com

    if (Times.isSameHour(period.getStart(), period.getEnd())) {
        hours.add(new TimeRange(period));
        return hours;
    }

    hours.add(new TimeRange(period.getStart(), Times.endTimeOfHour(period.getStart())));

    DateTime endHour = period.getEnd();
    DateTime current = Times.trimToHour(period.getStart(), period.getStart().getHourOfDay() + 1);
    ITimeCalendar calendar = TimeCalendar.getDefault();

    DateTime maxHour = endHour.minusHours(1);
    while (current.compareTo(maxHour) <= 0) {
        hours.add(Times.getHourRange(current, calendar));
        current = current.plusHours(1);
    }

    if (endHour.minusHours(endHour.getHourOfDay()).getMillisOfDay() > 0) {
        hours.add(new TimeRange(Times.startTimeOfHour(endHour), endHour));
    }

    return hours;
}

From source file:model.SqlInterface.java

/**
 * Used to generate the current tally of time spent today and this week.
 * /*from  ww  w  .  j a va 2s . c om*/
 * @param daySubTotal The current subtotal for today and this week.
 * 
 * @return Time object containing the total time for today and this week.
 */
public DateTime getDayTimeTotal(DateTime daySubTotal) {
    String day = "";
    String week = "";
    DateTime date = new DateTime();
    String dateString = "" + date.getYear() + date.getMonthOfYear() + date.getDayOfMonth();
    ResultSet rs;

    try {
        rs = statementHandler.executeQuery("select * from timelord where date = '" + dateString + "';");

        while (rs.next()) {
            day = rs.getString("dayTally");
            week = rs.getString("weekTally");
            System.out.println("SQL: " + day + " " + week);
            System.out.println("dayTally = " + rs.getString("dayTally"));
            System.out.println("weekTally = " + rs.getString("weekTally"));
            System.out.println("-----------------------------------------");
        }

        rs.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }

    DateTime time = new DateTime(0, 1, 1, 0, 0, 0, 0);
    try {
        time.plusHours(1);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return time;
}

From source file:net.chrissearle.flickrvote.web.admin.ChallengeAction.java

License:Apache License

@Override
public String execute() throws Exception {
    DateTime start = new DateTime(challenge.getStartDate());

    Date startDate = start.plusHours(FlickrVoteWebConstants.START_CHALLENGE_TIME).toDate();
    Date voteDate = start.plusDays(7).plusHours(FlickrVoteWebConstants.START_VOTE_TIME).toDate();
    Date endDate = start.plusDays(9).plusHours(FlickrVoteWebConstants.END_CHALLENGE_TIME).toDate();

    challengeService.saveChallenge(challenge.getTag(), challenge.getTitle(), challenge.getNotes(), startDate,
            voteDate, endDate);/*  w ww .j  a v a2  s  . c  o  m*/

    return SUCCESS;
}

From source file:net.ripe.rpki.commons.provisioning.ProvisioningObjectMother.java

License:BSD License

private static X509CRL generateCrl() {
    X509CrlBuilder builder = new X509CrlBuilder();
    builder.withIssuerDN(new X500Principal("CN=nl.bluelight"));
    builder.withAuthorityKeyIdentifier(TEST_KEY_PAIR.getPublic());
    DateTime now = new DateTime();
    builder.withThisUpdateTime(now);//ww  w . j ava  2  s  .  c om
    builder.withNextUpdateTime(now.plusHours(24));
    builder.withNumber(BigInteger.TEN);

    return builder.build(TEST_KEY_PAIR.getPrivate()).getCrl();
}

From source file:net.solarnetwork.central.dras.dao.ibatis.test.AbstractIbatisDaoTestSupport.java

License:Open Source License

/**
 * Insert a test event into the solardras.event table.
 *///from w  w  w  .j  a v a 2  s .c  o m
protected void setupTestEvent(Long eventId, Long programId) {
    DateTime eventDate = new DateTime(TEST_PROGRAM_DATE);
    simpleJdbcTemplate.update(
            "insert into solardras.program_event (id,creator,pro_id,notif_date,start_date,end_date,test) "
                    + "values (?,?,?,?,?,?,?)",
            eventId, TEST_USER_ID, programId, new java.sql.Timestamp(eventDate.minusHours(2).getMillis()),
            new java.sql.Timestamp(eventDate.getMillis()),
            new java.sql.Timestamp(eventDate.plusHours(1).getMillis()), Boolean.TRUE);
}

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

License:Open Source License

protected List<EvaluationEventBean> getAllEvents(String description, Registration registration) {
    List<EvaluationEventBean> result = new ArrayList<EvaluationEventBean>();
    String url = CoreConfiguration.getConfiguration().applicationUrl();

    Set<ExecutionCourse> executionCourses = new HashSet<ExecutionCourse>();
    executionCourses.addAll(this.getAttendingExecutionCoursesFor(registration));

    if (this.getEnrollmentBeginDayDateYearMonthDay() != null) {
        DateTime enrollmentBegin = convertTimes(this.getEnrollmentBeginDayDateYearMonthDay(),
                this.getEnrollmentBeginTimeDateHourMinuteSecond());
        DateTime enrollmentEnd = convertTimes(this.getEnrollmentEndDayDateYearMonthDay(),
                this.getEnrollmentEndTimeDateHourMinuteSecond());

        result.add(new EvaluationEventBean("Inicio das inscries para " + description, enrollmentBegin,
                enrollmentBegin.plusHours(1), false, null, url + "/login", null, executionCourses));

        result.add(// ww w .j a  v  a2 s. c  o m
                new EvaluationEventBean("Fim das inscries para " + description, enrollmentEnd.minusHours(1),
                        enrollmentEnd, false, null, url + "/login", null, executionCourses));
    }

    Set<Space> rooms = new HashSet<>();

    if (registration.getRoomFor(this) != null) {
        rooms.add(registration.getRoomFor(this));
    } else {
        for (WrittenEvaluationSpaceOccupation weSpaceOcupation : this
                .getWrittenEvaluationSpaceOccupationsSet()) {
            rooms.add(weSpaceOcupation.getRoom());
        }
    }

    result.add(new EvaluationEventBean(description, this.getBeginningDateTime(), this.getEndDateTime(), false,
            rooms, url + executionCourses.iterator().next().getSite().getReversePath(), null,
            executionCourses));

    return result;
}