Example usage for org.joda.time LocalTime LocalTime

List of usage examples for org.joda.time LocalTime LocalTime

Introduction

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

Prototype

public LocalTime(int hourOfDay, int minuteOfHour) 

Source Link

Document

Constructs an instance set to the specified time using ISOChronology.

Usage

From source file:au.com.scds.chats.dom.activity.Activities.java

License:Apache License

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.NEVER)
@MemberOrder(sequence = "7")
public List<ActivityEvent> listActivitiesInPeriod(
        @Parameter(optionality = Optionality.MANDATORY) @ParameterLayout(named = "Start Period") LocalDate start,
        @Parameter(optionality = Optionality.MANDATORY) @ParameterLayout(named = "End Period") LocalDate end) {
    return container
            .allMatches(new QueryDefault<>(ActivityEvent.class, "findActivitiesInPeriod", "startDateTime",
                    start.toDateTimeAtStartOfDay(), "endDateTime", end.toDateTime(new LocalTime(23, 59))));
}

From source file:au.com.scds.chats.dom.attendance.AttendanceLists.java

License:Apache License

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.NEVER)
@MemberOrder(sequence = "1.0")
public List<AttendanceList> listAttendanceListsInPeriod(
        @Parameter(optionality = Optionality.MANDATORY) @ParameterLayout(named = "Start Period") LocalDate start,
        @Parameter(optionality = Optionality.MANDATORY) @ParameterLayout(named = "End Period") LocalDate end) {
    return container
            .allMatches(new QueryDefault<>(AttendanceList.class, "findAttendanceListsInPeriod", "startDateTime",
                    start.toDateTimeAtStartOfDay(), "endDateTime", end.toDateTime(new LocalTime(23, 59))));
}

From source file:au.com.scds.chats.dom.attendance.AttendanceLists.java

License:Apache License

@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.NEVER, named = "List Attendances In Period")
@MemberOrder(sequence = "3.0")
public List<Attend> listAttendsInPeriod(
        @Parameter(optionality = Optionality.MANDATORY) @ParameterLayout(named = "Start Period") LocalDate start,
        @Parameter(optionality = Optionality.MANDATORY) @ParameterLayout(named = "End Period") LocalDate end) {
    return container.allMatches(new QueryDefault<>(Attend.class, "findAttendsInPeriod", "startDateTime",
            start.toDateTimeAtStartOfDay(), "endDateTime", end.toDateTime(new LocalTime(23, 59))));
}

From source file:business.RegistroBO.java

public LocalTime getLateTimeByMonth(Date dt) {
    LocalTime result = new LocalTime(0, 0);
    try {//w  w  w.  j a va2 s  .co  m
        List<Registro> list = registroDao.getListByMonth(dt);
        for (Registro reg : list) {
            LocalTime tmp = getLateTime(reg);
            if ((tmp.getHourOfDay() > 0) || (tmp.getMinuteOfHour() > 0)) {
                result = result.plusHours(tmp.getHourOfDay());
                result = result.plusMinutes(tmp.getMinuteOfHour());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:business.RegistroBO.java

/**
 *
 * @param beginDate//from  w ww  .j  ava 2  s .c  om
 * @param endDate
 * @return
 */
public LocalTime getOvertime(Date beginDate, Date endDate) {
    LocalTime result = new LocalTime(0, 0);
    try {
        List<Registro> list = registroDao.getListBetween(beginDate, endDate);
        for (Registro reg : list) {
            //zerando a data para comparar
            Calendar cal = Calendar.getInstance();
            cal.setTime(reg.getDate());
            Calendar dateCalendar = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
                    cal.get(Calendar.DAY_OF_MONTH));
            if ((dateCalendar.getTime().compareTo(beginDate) >= 0)
                    && (dateCalendar.getTime().compareTo(endDate) <= 0)) {

                LocalTime tmp = getLateLimitedTime(reg);
                //                    if ((tmp.getHourOfDay() > 0) || (tmp.getMinuteOfHour() > 0)) {
                //                        result = result.plusHours(tmp.getHourOfDay());
                //                        result = result.plusMinutes(tmp.getMinuteOfHour());
                //                    }
                if ((reg.getTotalHoras().getHourOfDay() >= Constants.TOTAL_LIMIT.getHourOfDay())
                        && (reg.getTotalHoras().getMinuteOfHour() >= Constants.TOTAL_LIMIT.getMinuteOfHour())) {
                    int h = (reg.getTotalHoras().getHourOfDay() + tmp.getHourOfDay())
                            - (Constants.TOTAL_LIMIT.getHourOfDay());
                    int m = tmp.getMinuteOfHour() + reg.getTotalHoras().getMinuteOfHour();
                    result = result.plusHours(h);
                    result = result.plusMinutes(m);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:business.RegistroBO.java

public LocalTime getLateTime(Registro reg) {
    LocalTime result = new LocalTime(0, 0);
    try {//from  w w w  .  j av a  2s.com
        //calcula o tempo que infrigiu o horrio ncleo
        result = getLateLimitedTime(reg);
        //calcula o tempo que falta para a carga diria de trabalho
        if ((reg.getTotalHoras().getHourOfDay() < Constants.TOTAL_LIMIT.getHourOfDay())
                && (reg.getTotalHoras().getMinuteOfHour() > Constants.TOTAL_LIMIT.getMinuteOfHour())) {
            int h = (Constants.TOTAL_LIMIT.getHourOfDay() - 1) - reg.getTotalHoras().getHourOfDay();
            int m = 60 - reg.getTotalHoras().getMinuteOfHour();
            result = result.plusHours(h - result.getHourOfDay());
            result = result.plusMinutes(m - result.getMinuteOfHour());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:business.RegistroBO.java

private LocalTime getLateLimitedTime(Registro reg) {
    LocalTime result = new LocalTime(0, 0);
    try {/*ww  w .j  a  va2s.  c o m*/
        if ((reg.getManha().getHourOfDay() >= Constants.MANHA_LIMIT.getHourOfDay())
                && (reg.getManha().getMinuteOfHour() > Constants.MANHA_LIMIT.getMinuteOfHour())) {
            int h = reg.getManha().getHourOfDay() - Constants.MANHA_LIMIT.getHourOfDay();
            int m = reg.getManha().getMinuteOfHour();
            result = result.plusHours(h);
            result = result.plusMinutes(m);
        }
        if ((reg.getAlmoco().getHourOfDay() < Constants.ALMOCO_LIMIT.getHourOfDay())
                && (reg.getAlmoco().getMinuteOfHour() >= Constants.ALMOCO_LIMIT.getMinuteOfHour())) {
            int h = (Constants.ALMOCO_LIMIT.getHourOfDay() - 1) - reg.getAlmoco().getHourOfDay();
            int m = 60 - reg.getAlmoco().getMinuteOfHour();
            result = result.plusHours(h);
            result = result.plusMinutes(m);
        }
        if ((reg.getAlmoco2().getHourOfDay() >= Constants.ALMOCO2_LIMIT.getHourOfDay())
                && (reg.getAlmoco2().getMinuteOfHour() > Constants.ALMOCO2_LIMIT.getMinuteOfHour())) {
            int h = reg.getAlmoco2().getHourOfDay() - Constants.ALMOCO2_LIMIT.getHourOfDay();
            int m = reg.getAlmoco2().getMinuteOfHour();
            result = result.plusHours(h);
            result = result.plusMinutes(m);
        }
        if ((reg.getTarde().getHourOfDay() < Constants.TARDE_LIMIT.getHourOfDay())
                && (reg.getTarde().getMinuteOfHour() >= Constants.TARDE_LIMIT.getMinuteOfHour())) {
            int h = (Constants.TARDE_LIMIT.getHourOfDay() - 1) - reg.getTarde().getHourOfDay();
            int m = 60 - reg.getTarde().getMinuteOfHour();
            result = result.plusHours(h);
            result = result.plusMinutes(m);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

From source file:com.alliander.osgp.domain.core.valueobjects.smartmetering.CosemTime.java

License:Open Source License

/**
 * Returns this {@link CosemTime} as {@link LocalTime} if {@code hour},
 * {@code minute} do not contain wildcard values.
 *
 * @return this {@link CosemTime} as {@link LocalTime}, or {@code null} if
 *         not {@link #isLocalTimeSpecified()}.
 *
 * @see #isLocalTimeSpecified()/* w  w w. j a v a 2  s  .  com*/
 */
public LocalTime asLocalTime() {
    if (!this.isLocalTimeSpecified()) {
        return null;
    }
    if (SECOND_NOT_SPECIFIED == this.second) {
        return new LocalTime(this.hour, this.minute);
    }
    if (HUNDREDTHS_NOT_SPECIFIED == this.hundredths) {
        return new LocalTime(this.hour, this.minute, this.second);
    }
    return new LocalTime(this.hour, this.minute, this.second, this.hundredths * 10);
}

From source file:com.axelor.apps.hr.service.timesheet.TimesheetServiceImp.java

License:Open Source License

@Transactional
public void insertTSLine(ActionRequest request, ActionResponse response) {

    User user = AuthUtils.getUser();/*from   w w w .  ja  va  2 s. co m*/
    ProjectTask projectTask = Beans.get(ProjectTaskRepository.class)
            .find(new Long(request.getData().get("project").toString()));
    Product product = Beans.get(ProductRepository.class)
            .find(new Long(request.getData().get("activity").toString()));
    LocalDate date = new LocalDate(request.getData().get("date").toString());
    if (user != null) {
        Timesheet timesheet = Beans.get(TimesheetRepository.class).all()
                .filter("self.statusSelect = 1 AND self.user.id = ?1", user.getId()).order("-id").fetchOne();
        if (timesheet == null) {
            timesheet = new Timesheet();
            timesheet.setUser(user);
            timesheet.setCompany(user.getActiveCompany());
            timesheet.setFromDate(date);
            timesheet.setToDate(date);
            timesheet.setStatusSelect(TimesheetRepository.STATUS_DRAFT);
        }
        TimesheetLine timesheetLine = new TimesheetLine();
        timesheetLine.setDate(date);
        timesheetLine.setComments(request.getData().get("comments").toString());
        timesheetLine.setProduct(product);
        timesheetLine.setProjectTask(projectTask);
        timesheetLine.setUser(user);
        timesheetLine.setToInvoice(new Boolean(request.getData().get("toInvoice").toString()));
        BigDecimal durationHours = new BigDecimal(Hours
                .hoursBetween(new LocalTime(0, 0), new LocalTime(request.getData().get("duration").toString()))
                .getHours());
        timesheetLine.setDurationStored(durationHours);
        timesheetLine.setVisibleDuration(durationHours);
        timesheet.addTimesheetLineListItem(timesheetLine);

        Beans.get(TimesheetRepository.class).save(timesheet);
    }
}

From source file:com.axelor.apps.hr.service.timesheet.TimesheetServiceImpl.java

License:Open Source License

@Transactional
public void insertTSLine(ActionRequest request, ActionResponse response) {

    User user = AuthUtils.getUser();//from  w  ww .ja  v  a  2 s  .  c  o  m
    ProjectTask projectTask = Beans.get(ProjectTaskRepository.class)
            .find(new Long(request.getData().get("project").toString()));
    Product product = Beans.get(ProductRepository.class)
            .find(new Long(request.getData().get("activity").toString()));
    LocalDate date = new LocalDate(request.getData().get("date").toString());
    if (user != null) {
        Timesheet timesheet = Beans.get(TimesheetRepository.class).all()
                .filter("self.statusSelect = 1 AND self.user.id = ?1", user.getId()).order("-id").fetchOne();
        if (timesheet == null) {
            timesheet = createTimesheet(user, date, date);
        }
        BigDecimal minutes = new BigDecimal(Minutes.minutesBetween(new LocalTime(0, 0),
                new LocalTime(request.getData().get("duration").toString())).getMinutes());
        createTimesheetLine(projectTask, product, user, date, timesheet, minutes,
                request.getData().get("comments").toString());

        Beans.get(TimesheetRepository.class).save(timesheet);
    }
}