Example usage for org.joda.time LocalDate fromDateFields

List of usage examples for org.joda.time LocalDate fromDateFields

Introduction

In this page you can find the example usage for org.joda.time LocalDate fromDateFields.

Prototype

@SuppressWarnings("deprecation")
public static LocalDate fromDateFields(Date date) 

Source Link

Document

Constructs a LocalDate from a java.util.Date using exactly the same field values.

Usage

From source file:org.kuali.kpme.tklm.time.missedpunch.MissedPunch.java

License:Educational Community License

public void setActionTime(String actionTime) {
    LocalDate localDate = actionDateTime != null ? LocalDate.fromDateFields(actionDateTime) : LocalDate.now();
    LocalTime localTime = actionTime != null ? FORMATTER.parseLocalTime(actionTime) : null;
    actionDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;/*  ww  w.  j  a  va 2s  . co  m*/
}

From source file:org.kuali.kpme.tklm.time.missedpunch.MissedPunchBo.java

License:Educational Community License

public Date getActionDate() {
    return actionDateTime != null ? LocalDate.fromDateFields(actionDateTime).toDate()
            : (getLocalDate() != null ? getLocalDate().toDate() : null);
}

From source file:org.kuali.kpme.tklm.time.missedpunch.MissedPunchBo.java

License:Educational Community License

public void setActionDate(Date actionDate) {
    setLocalDate(actionDate != null ? LocalDate.fromDateFields(actionDate) : null);
    //LocalTime localTime = actionDateTime != null ? LocalTime.fromDateFields(actionDateTime) : LocalTime.MIDNIGHT;
    if (localDate != null && localTime != null) {
        actionDateTime = localDate.toDateTime(localTime).toDate();
    }/*from w ww. j  a v a 2 s. c  o m*/
}

From source file:org.kuali.kpme.tklm.time.workflow.postprocessor.TkPostProcessor.java

License:Educational Community License

private void calculateLeaveCalendarOvertime(TimesheetDocumentHeader timesheetDocumentHeader,
        DocumentStatus newDocumentStatus) {
    if (DocumentStatus.FINAL.equals(newDocumentStatus)) {
        String documentId = timesheetDocumentHeader.getDocumentId();
        String principalId = timesheetDocumentHeader.getPrincipalId();
        DateTime endDate = timesheetDocumentHeader.getEndDateTime();

        if (LmServiceLocator.getLeaveApprovalService().isActiveAssignmentFoundOnJobFlsaStatus(principalId,
                HrConstants.FLSA_STATUS_NON_EXEMPT, true)) {
            List<TimeBlock> timeBlocks = TkServiceLocator.getTimeBlockService().getTimeBlocks(documentId);

            List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>();

            for (TimeBlock timeBlock : timeBlocks) {
                EarnCode overtimeEarnCode = getOvertimeEarnCode(timeBlock, endDate.toLocalDate());

                if (overtimeEarnCode != null) {
                    AccrualCategory accrualCategory = HrServiceLocator.getAccrualCategoryService()
                            .getAccrualCategory(overtimeEarnCode.getAccrualCategory(), endDate.toLocalDate());

                    if (accrualCategory != null) {
                        LocalDate leaveDate = LocalDate.fromDateFields(timeBlock.getBeginDate());
                        BigDecimal leaveAmount = timeBlock.getHours();
                        //What if [can] the units are [be] days?

                        LeaveBlock.Builder builder = new LeaveBlock.Builder(leaveDate, null, principalId,
                                overtimeEarnCode.getEarnCode(), leaveAmount)
                                        .accrualCategory(accrualCategory.getAccrualCategory())
                                        .leaveBlockType(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE)
                                        .requestStatus(HrConstants.REQUEST_STATUS.APPROVED);

                        leaveBlocks.add(builder.build());
                    }//from   w  ww  .  ja v  a2s .c  o m
                }
            }

            LmServiceLocator.getLeaveBlockService().saveLeaveBlocks(leaveBlocks);
        }
    }
}

From source file:org.libreplan.business.orders.daos.OrderDAO.java

License:Open Source License

/**
 * If both params are <code>null</code> it returns <code>null</code>.
 * Otherwise it filters the list of tasks to return the ones without parent between the dates.
 *///from   w w w.  ja v a2 s . c om
private List<Long> getOrdersIdsByDates(Date startDate, Date endDate) {
    if (startDate == null && endDate == null) {
        /* Don't replace null with Collections.emptyList(), as the prompt says (sometimes), because it breaks logic */
        return null;
    }

    String strQuery = "SELECT t.taskSource.schedulingData.orderElement.id " + "FROM TaskElement t "
            + "WHERE t.parent IS NULL ";

    if (endDate != null) {
        strQuery += "AND t.startDate.date <= :endDate ";
    }

    if (startDate != null) {
        strQuery += "AND t.endDate.date >= :startDate ";
    }

    Query query = getSession().createQuery(strQuery);

    if (startDate != null) {
        query.setParameter("startDate", LocalDate.fromDateFields(startDate));
    }

    if (endDate != null) {
        query.setParameter("endDate", LocalDate.fromDateFields(endDate));
    }

    return query.list();
}

From source file:org.libreplan.business.orders.entities.OrderElement.java

License:Open Source License

protected boolean applyConstraintBasedOnInitOrEndDate(Task task, boolean scheduleBackwards) {
    TaskPositionConstraint constraint = task.getPositionConstraint();

    if (getInitDate() != null && (getDeadline() == null || !scheduleBackwards)) {
        constraint.notEarlierThan(IntraDayDate.startOfDay(LocalDate.fromDateFields(this.getInitDate())));
        return true;
    }//  w w w  .j  a va  2  s  . c  om

    return false;
}

From source file:org.libreplan.business.planner.daos.ResourceAllocationDAO.java

License:Open Source License

private static LocalDate asLocalDate(Date date) {
    if (date == null) {
        return null;
    }/*from  w w w  . j a va  2s . c  om*/
    return LocalDate.fromDateFields(date);
}

From source file:org.libreplan.business.planner.daos.TaskElementDAO.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
public List<TaskElement> listFilteredByDate(Date start, Date end) {
    Criteria criteria = getSession().createCriteria(TaskElement.class);
    if (start != null) {
        criteria.add(Restrictions.ge("endDate.date", LocalDate.fromDateFields(start)));
    }/*from w ww  .jav a 2  s . c  o m*/
    if (end != null) {
        criteria.add(Restrictions.le("startDate.date", LocalDate.fromDateFields(end)));
    }
    return criteria.list();
}

From source file:org.libreplan.business.planner.entities.TaskElement.java

License:Open Source License

public void setStartDate(Date startDate) {
    setIntraDayStartDate(IntraDayDate.startOfDay(LocalDate.fromDateFields(startDate)));
}

From source file:org.libreplan.business.planner.entities.TaskElement.java

License:Open Source License

public void setEndDate(Date endDate) {
    setIntraDayEndDate(/*from   www  . j av  a2s . co m*/
            (endDate != null) ? IntraDayDate.create(LocalDate.fromDateFields(endDate), EffortDuration.zero())
                    : null);
}