Example usage for org.joda.time LocalDateTime withTime

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

Introduction

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

Prototype

public LocalDateTime withTime(int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) 

Source Link

Document

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

Usage

From source file:com.axelor.apps.organisation.service.PlanningLineService.java

License:Open Source License

public LocalDateTime getSpecificDateTime(LocalDateTime dateTime, int hour, int minute, int second,
        int millissecond) {

    return dateTime.withTime(hour, minute, second, millissecond);
}

From source file:com.effektif.workflow.api.model.AfterRelativeTime.java

License:Apache License

public LocalDateTime resolve(LocalDateTime base) {
    if (this.duration == null || this.durationUnit == null) {
        return null;
    }/*  ww  w.  j av a  2s .  c o m*/

    ReadablePeriod period = null;
    if (DAYS.equals(durationUnit)) {
        period = Days.days(getDurationAsInt());
    } else if (WEEKS.equals(durationUnit)) {
        period = Weeks.weeks(getDurationAsInt());
    } else if (HOURS.equals(durationUnit)) {
        period = Hours.hours(getDurationAsInt());
    } else if (MONTHS.equals(durationUnit)) {
        period = Months.months(getDurationAsInt());
    } else if (YEARS.equals(durationUnit)) {
        period = Years.years(getDurationAsInt());
    } else if (MINUTES.equals(durationUnit)) {
        period = Minutes.minutes(getDurationAsInt());
    } else {
        return null;
    }

    LocalDateTime time = base.plus(period);

    if (atHour != null) {
        LocalDateTime atTime = time.withTime(atHour, atMinute != null ? atMinute : 0, 0, 0);
        if (atTime.isBefore(time)) {
            time = atTime.plusDays(1);
        } else {
            time = atTime;
        }
    } else if (isDayResolutionOrBigger()) {
        time = time.withTime(23, 59, 59, 999);
    }

    return time;
}

From source file:com.effektif.workflow.api.model.NextRelativeTime.java

License:Apache License

@Override
public LocalDateTime resolve(LocalDateTime base) {
    LocalDateTime time = null;//from   ww  w . ja v a 2s. c  om
    if (HOUR_OF_DAY.equals(indexUnit)) {
        time = base.withTime(index, 0, 0, 0);
        if (!time.isAfter(base)) {
            return time.plusDays(1);
        }
    } else if (DAY_OF_WEEK.equals(indexUnit)) {
        time = base.withDayOfWeek(index).withTime(0, 0, 0, 0);
        if (!time.isAfter(base)) {
            time = time.plusWeeks(1);
        }
    } else if (DAY_OF_MONTH.equals(indexUnit)) {
        time = base.withDayOfMonth(index).withTime(0, 0, 0, 0);
        if (!time.isAfter(base)) {
            time = time.plusMonths(1);
        }
    }
    if (atHour != null) {
        time = time.withTime(atHour, atMinute != null ? atMinute : 0, 0, 0);
    }
    return time;
}

From source file:org.codeqinvest.codechanges.scm.svn.DefaultSvnRevisionsRetriever.java

License:Open Source License

/**
 * {@inheritDoc}//from  ww  w .ja  v a 2  s  . co m
 */
@Override
@Cacheable("svnRevisions")
public DailyRevisions retrieveRevisions(ScmConnectionSettings connectionSettings, LocalDate day)
        throws SVNException {
    log.info("Retrieve revisions on day {} for {}", day, connectionSettings);
    final SVNRepository repository = SvnRepositoryFactory.create(connectionSettings);
    final LocalDateTime startTime = day.toDateTimeAtStartOfDay().toLocalDateTime();
    final long startRevision = repository.getDatedRevision(startTime.toDate());
    final long endRevision = repository.getDatedRevision(startTime.withTime(23, 59, 59, 999).toDate());

    final Multimap<String, SvnFileRevision> revisions = ArrayListMultimap.create();
    repository.log(null, startRevision, endRevision, true, true, new ISVNLogEntryHandler() {

        @Override
        public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
            for (SVNLogEntryPath logEntryPath : logEntry.getChangedPaths().values()) {
                if (logEntryPath.getCopyPath() != null) {
                    revisions.put(logEntryPath.getPath(), new SvnFileRevision(logEntry.getRevision(),
                            logEntryPath.getCopyPath(), logEntryPath.getPath()));
                } else {
                    revisions.put(logEntryPath.getPath(), new SvnFileRevision(logEntry.getRevision(),
                            logEntryPath.getPath(), logEntryPath.getPath()));
                }
            }
        }
    });

    log.info("Found {} changes for day {} with connection {}", revisions.values().size(), day,
            connectionSettings);
    return new DailyRevisions(day, revisions);
}

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

/**
 * isWithinWeek/* w w  w  .  j a va2s . c  om*/
 * 
 * @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);
}