Example usage for org.joda.time LocalDate now

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

Introduction

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

Prototype

public static LocalDate now() 

Source Link

Document

Obtains a LocalDate set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:org.kuali.kpme.tklm.time.clock.web.ClockAction.java

License:Educational Community License

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionForward actionForward = super.execute(mapping, form, request, response);

    ClockActionForm clockActionForm = (ClockActionForm) form;

    TimesheetDocument timesheetDocument = clockActionForm.getTimesheetDocument();

    if (timesheetDocument != null) {
        if (!timesheetDocument.getDocumentHeader().getDocumentStatus().equals(HrConstants.ROUTE_STATUS.ENROUTE)
                && !timesheetDocument.getDocumentHeader().getDocumentStatus()
                        .equals(HrConstants.ROUTE_STATUS.FINAL)) {

            String targetPrincipalId = HrContext.getTargetPrincipalId();
            if (targetPrincipalId != null) {
                clockActionForm.setPrincipalId(targetPrincipalId);
            }// w ww  .ja v  a2  s . c o  m
            clockActionForm.setAssignmentDescriptions(timesheetDocument.getAssignmentDescriptions(true));

            if (clockActionForm.getEditTimeBlockId() != null) {
                clockActionForm.setCurrentTimeBlock(TkServiceLocator.getTimeBlockService()
                        .getTimeBlock(clockActionForm.getEditTimeBlockId()));
            }

            ClockLog lastClockLog = TkServiceLocator.getClockLogService().getLastClockLog(targetPrincipalId);
            if (lastClockLog != null) {
                DateTime lastClockDateTime = lastClockLog.getClockDateTime();
                String lastClockZone = lastClockLog.getClockTimestampTimezone();
                if (StringUtils.isEmpty(lastClockZone)) {
                    lastClockZone = TKUtils.getSystemTimeZone();
                }
                // zone will not be null. At this point is Valid or Exception.
                // Exception would indicate bad data stored in the system. We can wrap this, but
                // for now, the thrown exception is probably more valuable.
                DateTimeZone zone = DateTimeZone.forID(lastClockZone);
                DateTime clockWithZone = lastClockDateTime.withZone(zone);
                clockActionForm.setLastClockTimeWithZone(clockWithZone.toDate());
                clockActionForm.setLastClockTimestamp(lastClockDateTime.toDate());
                clockActionForm.setLastClockAction(lastClockLog.getClockAction());
            }

            if (lastClockLog == null
                    || StringUtils.equals(lastClockLog.getClockAction(), TkConstants.CLOCK_OUT)) {
                clockActionForm.setCurrentClockAction(TkConstants.CLOCK_IN);
            } else {
                if (StringUtils.equals(lastClockLog.getClockAction(), TkConstants.LUNCH_OUT)
                        && TkServiceLocator.getSystemLunchRuleService().isShowLunchButton()) {
                    clockActionForm.setCurrentClockAction(TkConstants.LUNCH_IN);
                } else {
                    clockActionForm.setCurrentClockAction(TkConstants.CLOCK_OUT);
                }
                // if the current clock action is clock out, displays only the clocked-in assignment
                String selectedAssignment = new AssignmentDescriptionKey(lastClockLog.getJobNumber(),
                        lastClockLog.getWorkArea(), lastClockLog.getTask()).toAssignmentKeyString();
                clockActionForm.setSelectedAssignment(selectedAssignment);
                Assignment assignment = timesheetDocument
                        .getAssignment(AssignmentDescriptionKey.get(selectedAssignment));
                Map<String, String> assignmentDesc = HrServiceLocator.getAssignmentService()
                        .getAssignmentDescriptions(assignment);
                clockActionForm.setAssignmentDescriptions(assignmentDesc);
            }

            if (StringUtils.equals(GlobalVariables.getUserSession().getPrincipalId(),
                    HrContext.getTargetPrincipalId())) {
                clockActionForm.setClockButtonEnabled(true);
            } else {
                boolean isApproverOrReviewerForCurrentAssignment = false;
                String selectedAssignment = StringUtils.EMPTY;
                if (clockActionForm.getAssignmentDescriptions() != null) {
                    if (clockActionForm.getAssignmentDescriptions().size() == 1) {
                        for (String assignment : clockActionForm.getAssignmentDescriptions().keySet()) {
                            selectedAssignment = assignment;
                        }
                    } else {
                        selectedAssignment = clockActionForm.getSelectedAssignment();
                    }
                }

                Assignment assignment = HrServiceLocator.getAssignmentService()
                        .getAssignment(AssignmentDescriptionKey.get(selectedAssignment), LocalDate.now());
                if (assignment != null) {
                    String principalId = GlobalVariables.getUserSession().getPrincipalId();
                    Long workArea = assignment.getWorkArea();
                    isApproverOrReviewerForCurrentAssignment = HrServiceLocator.getKPMERoleService()
                            .principalHasRoleInWorkArea(principalId, KPMENamespace.KPME_HR.getNamespaceCode(),
                                    KPMERole.APPROVER.getRoleName(), workArea, new DateTime())
                            || HrServiceLocator.getKPMERoleService().principalHasRoleInWorkArea(principalId,
                                    KPMENamespace.KPME_HR.getNamespaceCode(),
                                    KPMERole.APPROVER_DELEGATE.getRoleName(), workArea, new DateTime())
                            || HrServiceLocator.getKPMERoleService().principalHasRoleInWorkArea(principalId,
                                    KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.REVIEWER.getRoleName(),
                                    workArea, new DateTime());
                }
                clockActionForm.setClockButtonEnabled(isApproverOrReviewerForCurrentAssignment);
            }

            clockActionForm
                    .setShowLunchButton(TkServiceLocator.getSystemLunchRuleService().isShowLunchButton());
            assignShowDistributeButton(clockActionForm);

            if (clockActionForm.isShowLunchButton()) {
                // We don't need to worry about the assignments and lunch rules
                // if the global lunch rule is turned off.

                // Check for presence of department lunch rule.
                Map<String, Boolean> assignmentDeptLunchRuleMap = new HashMap<String, Boolean>();
                for (Assignment a : timesheetDocument.getAssignments()) {
                    String key = AssignmentDescriptionKey.getAssignmentKeyString(a);
                    DeptLunchRule deptLunchRule = TkServiceLocator.getDepartmentLunchRuleService()
                            .getDepartmentLunchRule(a.getDept(), a.getWorkArea(),
                                    clockActionForm.getPrincipalId(), a.getJobNumber(), LocalDate.now());
                    assignmentDeptLunchRuleMap.put(key, deptLunchRule != null);
                }
                clockActionForm.setAssignmentLunchMap(assignmentDeptLunchRuleMap);
            }
        } else {
            clockActionForm.setErrorMessage(
                    "Your current timesheet is already submitted for Approval. Clock action is not allowed on this timesheet.");
        }
    }

    return actionForward;
}

From source file:org.kuali.kpme.tklm.time.clock.web.ClockAction.java

License:Educational Community License

@CacheEvict(value = { WorkArea.CACHE_NAME }, allEntries = true)
public ActionForward clockAction(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ClockActionForm caf = (ClockActionForm) form;

    // TODO: Validate that clock action is valid for this user
    // TODO: this needs to be integrated with the error tag
    if (StringUtils.isBlank(caf.getSelectedAssignment())) {
        caf.setErrorMessage("No assignment selected.");
        return mapping.findForward("basic");
    }//from w  w w  . j  av  a2 s  .  com
    ClockLog previousClockLog = TkServiceLocator.getClockLogService()
            .getLastClockLog(HrContext.getTargetPrincipalId());
    if (previousClockLog != null
            && StringUtils.equals(caf.getCurrentClockAction(), previousClockLog.getClockAction())) {
        caf.setErrorMessage("The operation is already performed.");
        return mapping.findForward("basic");
    }
    String ip = TKUtils.getIPAddressFromRequest(request.getRemoteAddr());
    Assignment assignment = caf.getTimesheetDocument()
            .getAssignment(AssignmentDescriptionKey.get(caf.getSelectedAssignment()));

    List<Assignment> lstAssingmentAsOfToday = HrServiceLocator.getAssignmentService()
            .getAssignments(HrContext.getTargetPrincipalId(), LocalDate.now());
    boolean foundValidAssignment = false;
    for (Assignment assign : lstAssingmentAsOfToday) {
        if ((assign.getJobNumber().compareTo(assignment.getJobNumber()) == 0)
                && (assign.getWorkArea().compareTo(assignment.getWorkArea()) == 0)
                && (assign.getTask().compareTo(assignment.getTask()) == 0)) {
            foundValidAssignment = true;
            break;
        }
    }

    if (!foundValidAssignment) {
        caf.setErrorMessage("Assignment is not effective as of today");
        return mapping.findForward("basic");
    }

    ClockLog clockLog = TkServiceLocator.getClockLogService().processClockLog(new DateTime(), assignment,
            caf.getCalendarEntry(), ip, LocalDate.now(), caf.getTimesheetDocument(),
            caf.getCurrentClockAction(), true, HrContext.getTargetPrincipalId());

    caf.setClockLog(clockLog);

    return mapping.findForward("basic");
}

From source file:org.kuali.kpme.tklm.time.clocklog.web.ClockLogLookupableHelper.java

License:Educational Community License

private List<ClockLog> filterByPrincipalId(List<ClockLog> clockLogs, String principalId) {
    List<ClockLog> results = new ArrayList<ClockLog>();

    for (ClockLog clockLog : clockLogs) {
        if (clockLog.getDocumentId() == null) {
            TimesheetDocumentHeader tsdh = TkServiceLocator.getTimesheetDocumentHeaderService()
                    .getDocumentHeaderForDate(clockLog.getPrincipalId(), clockLog.getClockDateTime());
            if (tsdh != null) {
                clockLog.setDocumentId(tsdh.getDocumentId());
            }//from   w ww . j a v a 2  s  .  c  o m
        }

        Job jobObj = HrServiceLocator.getJobService().getJob(clockLog.getPrincipalId(), clockLog.getJobNumber(),
                LocalDate.now(), false);
        String department = jobObj != null ? jobObj.getDept() : null;

        Department departmentObj = jobObj != null
                ? HrServiceLocator.getDepartmentService().getDepartment(department,
                        jobObj.getEffectiveLocalDate())
                : null;
        String location = departmentObj != null ? departmentObj.getLocation() : null;

        Map<String, String> roleQualification = new HashMap<String, String>();
        roleQualification.put(KimConstants.AttributeConstants.PRINCIPAL_ID,
                GlobalVariables.getUserSession().getPrincipalId());
        roleQualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department);
        roleQualification.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), location);

        if (!KimApiServiceLocator.getPermissionService().isPermissionDefinedByTemplate(
                KPMENamespace.KPME_WKFLW.getNamespaceCode(),
                KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(),
                new HashMap<String, String>())
                || KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(principalId,
                        KPMENamespace.KPME_WKFLW.getNamespaceCode(),
                        KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(),
                        new HashMap<String, String>(), roleQualification)) {
            results.add(clockLog);
        }
    }

    return results;
}

From source file:org.kuali.kpme.tklm.time.detail.web.ActionFormUtils.java

License:Educational Community License

public static int getPlanningMonthsForEmployee(String principalid) {
    int plannningMonths = 0;
    PrincipalHRAttributes principalHRAttributes = HrServiceLocator.getPrincipalHRAttributeService()
            .getPrincipalCalendar(principalid, LocalDate.now());
    if (principalHRAttributes != null && principalHRAttributes.getLeavePlan() != null) {
        LeavePlan lp = HrServiceLocator.getLeavePlanService().getLeavePlan(principalHRAttributes.getLeavePlan(),
                LocalDate.now());
        if (lp != null && lp.getPlanningMonths() != null) {
            plannningMonths = Integer.parseInt(lp.getPlanningMonths());
        }//from   w w  w.j  a v a  2  s  .  c  o m
    }
    return plannningMonths;
}

From source file:org.kuali.kpme.tklm.time.detail.web.TimeDetailWSAction.java

License:Educational Community License

public ActionForward getDepartmentForJobNumber(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    KualiMaintenanceForm kualiForm = (KualiMaintenanceForm) form;

    String principalId = (String) request.getAttribute("principalId");
    Long jobNumber = (Long) request.getAttribute("jobNumber");

    Job job = HrServiceLocator.getJobService().getJob(principalId, jobNumber, LocalDate.now());
    kualiForm.setAnnotation(job.getDept());

    return mapping.findForward("ws");
}

From source file:org.kuali.kpme.tklm.time.detail.web.TimeDetailWSAction.java

License:Educational Community License

public ActionForward getOvertimeEarnCodes(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    TimeDetailWSActionForm tdaf = (TimeDetailWSActionForm) form;
    List<EarnCode> overtimeEarnCodes = HrServiceLocator.getEarnCodeService()
            .getOvertimeEarnCodes(LocalDate.now());
    List<Map<String, Object>> overtimeEarnCodeList = new LinkedList<Map<String, Object>>();

    if (StringUtils.isNotEmpty(tdaf.getTkTimeBlockId())) {
        TimeBlock tb = TkServiceLocator.getTimeBlockService().getTimeBlock(tdaf.getTkTimeBlockId());
        if (tb != null) {
            Job job = HrServiceLocator.getJobService().getJob(HrContext.getTargetPrincipalId(),
                    tb.getJobNumber(), tb.getEndDateTime().toLocalDate());
            if (job != null) {
                for (EarnCode earnCode : overtimeEarnCodes) {
                    String employee = HrContext.isActiveEmployee() ? "Y" : null;
                    String approver = HrContext.isApprover() ? "Y" : null;
                    String payrollProcessor = HrContext.isPayrollProcessor() ? "Y" : null; // KPME-2532

                    List<EarnCodeSecurity> securityList = HrServiceLocator.getEarnCodeSecurityService()
                            .getEarnCodeSecurityList(job.getDept(), job.getHrSalGroup(), earnCode.getEarnCode(),
                                    employee, approver, payrollProcessor, job.getLocation(), "Y",
                                    tb.getEndDateTime().toLocalDate());
                    if (CollectionUtils.isNotEmpty(securityList)) {
                        Map<String, Object> earnCodeMap = new HashMap<String, Object>();
                        earnCodeMap.put("earnCode", earnCode.getEarnCode());
                        earnCodeMap.put("desc", earnCode.getDescription());
                        overtimeEarnCodeList.add(earnCodeMap);
                    }//from   w ww  .j  a  v  a  2s.  c o  m
                }
            }
        }

    }
    LOG.info(tdaf.toString());
    tdaf.setOutputString(JSONValue.toJSONString(overtimeEarnCodeList));
    return mapping.findForward("ws");
}

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;/* w  w w  . j av a2s  .co  m*/
}

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

License:Educational Community License

@Override
public List<KeyValue> getKeyValues(ViewModel model) {
    List<KeyValue> labels = new ArrayList<KeyValue>();

    if (model instanceof MissedPunchForm) {
        MissedPunchForm missedPunchForm = (MissedPunchForm) model;
        MissedPunchDocument missedPunchDocument = (MissedPunchDocument) missedPunchForm.getDocument();
        MissedPunchBo mp = missedPunchDocument == null ? missedPunchForm.getMissedPunch()
                : missedPunchDocument.getMissedPunch();
        LocalDate mpDate = mp.getLocalDate();
        if (mpDate == null) {
            mpDate = mp.getActionLocalDate();
            if (mpDate == null) {
                mpDate = LocalDate.now();
            }/* w w w  . j a  v  a2s .  co  m*/
        }
        String timesheetDocumentId = missedPunchDocument != null
                ? missedPunchDocument.getMissedPunch().getTimesheetDocumentId()
                : missedPunchForm.getMissedPunch().getTimesheetDocumentId();
        if (StringUtils.isNotBlank(timesheetDocumentId)) {
            TimesheetDocument timesheetDocument = TkServiceLocator.getTimesheetService()
                    .getTimesheetDocument(timesheetDocumentId);

            Map<LocalDate, List<Assignment>> assignmentMap = timesheetDocument.getAssignmentMap();
            List<Assignment> assignments = assignmentMap.get(mpDate);

            Interval calEntryInterval = new Interval(
                    timesheetDocument.getCalendarEntry().getBeginPeriodFullDateTime(),
                    timesheetDocument.getCalendarEntry().getEndPeriodFullDateTime());
            if (CollectionUtils.isEmpty(assignments)
                    && !calEntryInterval.contains(mpDate.toDateTimeAtStartOfDay())) {
                assignments = KpmeUtils.getUniqueAssignments(HrServiceLocator.getAssignmentService()
                        .getAssignmentHistoryBetweenDays(timesheetDocument.getPrincipalId(), mpDate, mpDate));
            }

            if (CollectionUtils.isEmpty(assignments)) {
                assignments = Collections.emptyList();
            }

            //            if (assignments.size() > 1) {
            //               labels.add(new ConcreteKeyValue("", ""));
            //            }

            if (missedPunchForm.getIpAddress() != null) {
                String ipAddress = TKUtils.getIPAddressFromRequest(missedPunchForm.getIpAddress());

                //Map<String, String> assignmentDescMap = timesheetDocument.getAssignmentDescriptions(true, mpDate);
                String targetPrincipalId = HrContext.getTargetPrincipalId();
                String principalId = HrContext.getPrincipalId();
                if (targetPrincipalId.equals(principalId)) {
                    DateTime currentDateTime = new DateTime();
                    for (Assignment assignment : assignments) {
                        //Assignment assignment = timesheetDocument.getAssignment(AssignmentDescriptionKey.get(entry.getKey()), LocalDate.now());
                        String allowActionFromInvalidLocation = ConfigContext.getCurrentContextConfig()
                                .getProperty(LMConstants.ALLOW_CLOCKINGEMPLOYYE_FROM_INVALIDLOCATION);
                        if (StringUtils.equals(allowActionFromInvalidLocation, "false")) {
                            boolean isInvalid = TkServiceLocator.getClockLocationRuleService()
                                    .isInvalidIPClockLocation(assignment.getGroupKeyCode(),
                                            assignment.getDept(), assignment.getWorkArea(),
                                            assignment.getPrincipalId(), assignment.getJobNumber(), ipAddress,
                                            currentDateTime.toLocalDate());
                            if (!isInvalid) {
                                labels.add(new ConcreteKeyValue(assignment.getAssignmentKey(),
                                        assignment.getAssignmentDescription()));
                            }
                        }
                    }
                } else {
                    for (Assignment assignment : assignments) {
                        labels.add(new ConcreteKeyValue(assignment.getAssignmentKey(),
                                assignment.getAssignmentDescription()));
                    }
                }
            } else {
                if (CollectionUtils.isNotEmpty(assignments)) {
                    for (Assignment assignment : assignments) {
                        labels.add(new ConcreteKeyValue(assignment.getAssignmentKey(),
                                assignment.getAssignmentDescription()));
                    }
                }
            }
        }
    }
    if (labels.size() > 1) {
        List<KeyValue> newLables = new ArrayList<KeyValue>();
        newLables.add(new ConcreteKeyValue("", ""));
        newLables.addAll(labels);
        labels = newLables;
    }
    if (labels.size() == 0) {
        labels.add(new ConcreteKeyValue("", "--- No asssignments for date  ---"));
    }
    return labels;
}

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

License:Educational Community License

@Override
public List<KeyValue> getKeyValues(ViewModel model) {
    List<KeyValue> keyLabels = new ArrayList<KeyValue>();

    Set<String> availableActions = new HashSet<String>();

    if (model instanceof MissedPunchForm) {
        MissedPunchForm missedPunchForm = (MissedPunchForm) model;
        MissedPunchDocument missedPunchDocument = (MissedPunchDocument) missedPunchForm.getDocument();

        String clockAction = missedPunchDocument != null ? missedPunchDocument.getMissedPunch().getClockAction()
                : missedPunchForm.getMissedPunch().getClockAction();
        if (StringUtils.isNotBlank(clockAction)) {
            availableActions.addAll(TkConstants.CLOCK_AVAILABLE_ACTION_MAP.get(clockAction));
        } else {//from   w w w  .  ja  v a  2  s.com
            ClockLog lastClock = TkServiceLocator.getClockLogService()
                    .getLastClockLog(HrContext.getTargetPrincipalId());
            availableActions.addAll(
                    lastClock != null ? TkConstants.CLOCK_ACTION_TRANSITION_MAP.get(lastClock.getClockAction())
                            : TkConstants.CLOCK_ACTION_TRANSITION_MAP.get(TkConstants.CLOCK_OUT));

            if (lastClock != null) {
                Job jobObj = HrServiceLocator.getJobService().getJob(HrContext.getTargetPrincipalId(),
                        lastClock.getJobNumber(), LocalDate.now());
                String department = jobObj != null ? jobObj.getDept() : null;
                Long workArea = lastClock.getWorkArea();
                Long jobNumber = lastClock.getJobNumber();

                SystemLunchRule systemLunchRule = TkServiceLocator.getSystemLunchRuleService()
                        .getSystemLunchRule(LocalDate.now());
                DeptLunchRule departmentLunchRule = TkServiceLocator.getDepartmentLunchRuleService()
                        .getDepartmentLunchRule(department, workArea, HrContext.getTargetPrincipalId(),
                                jobNumber, LocalDate.now());
                if (systemLunchRule == null || !systemLunchRule.getShowLunchButton()) {
                    availableActions.remove(TkConstants.LUNCH_OUT);
                    availableActions.remove(TkConstants.LUNCH_IN);
                } else {
                    if (departmentLunchRule != null) {
                        availableActions.remove(TkConstants.LUNCH_OUT);
                        availableActions.remove(TkConstants.LUNCH_IN);
                    }
                }
            }
        }
    } else {
        availableActions.addAll(TkConstants.CLOCK_ACTION_STRINGS.keySet());
    }

    if (availableActions.size() > 1) {
        keyLabels.add(new ConcreteKeyValue("", ""));
    }
    for (String availableAction : availableActions) {
        keyLabels.add(
                new ConcreteKeyValue(availableAction, TkConstants.CLOCK_ACTION_STRINGS.get(availableAction)));
    }

    return keyLabels;
}

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

License:Educational Community License

@Override
public MissedPunch addClockLog(MissedPunch missedPunch, String ipAddress) {
    MissedPunch.Builder builder = MissedPunch.Builder.create(missedPunch);
    TimesheetDocument timesheetDocument = timesheetService
            .getTimesheetDocument(missedPunch.getTimesheetDocumentId());
    AssignmentDescriptionKey assignmentDescriptionKey = new AssignmentDescriptionKey(
            missedPunch.getGroupKeyCode(), missedPunch.getJobNumber(), missedPunch.getWorkArea(),
            missedPunch.getTask());//from  w  ww.j a  va2  s.  com
    Assignment assignment = HrServiceLocator.getAssignmentService().getAssignment(missedPunch.getPrincipalId(),
            assignmentDescriptionKey, missedPunch.getActionLocalDate());
    CalendarEntry calendarEntry = timesheetDocument.getCalendarEntry();

    // use the actual date and time from the document to build the date time with user zone, then apply system time zone to it
    String dateString = TKUtils.formatDateTimeShort(missedPunch.getActionFullDateTime());
    String longDateString = TKUtils.formatDateTimeLong(missedPunch.getActionFullDateTime());
    String timeString = TKUtils.formatTimeShort(longDateString);

    DateTime dateTimeWithUserZone = TKUtils.convertDateStringToDateTime(dateString, timeString);
    DateTime actionDateTime = dateTimeWithUserZone.withZone(TKUtils.getSystemDateTimeZone());

    String clockAction = missedPunch.getClockAction();
    String principalId = timesheetDocument.getPrincipalId();

    ClockLog clockLog = clockLogService.processClockLog(principalId, timesheetDocument.getDocumentId(),
            actionDateTime, assignment, calendarEntry, ipAddress, LocalDate.now(), clockAction, false);

    clockLog = clockLogService.saveClockLog(clockLog);
    builder.setTkClockLogId(clockLog.getTkClockLogId());

    if (StringUtils.equals(clockLog.getClockAction(), TkConstants.CLOCK_OUT)
            || StringUtils.equals(clockLog.getClockAction(), TkConstants.LUNCH_OUT)) {
        ClockLog lastClockLog = clockLogService.getLastClockLog(missedPunch.getPrincipalId());
        // KPME-2735 This is where it creates a zero timeblock...  So we will check the clock id of clockLog and lastClockLog and 
        // if they are the same, we will assume it's trying to create a zero timeblock for the same clock action, therefore skip the code 
        if (!clockLog.getTkClockLogId().equals(lastClockLog.getTkClockLogId())) {
            String earnCode = assignment.getJob().getPayTypeObj().getRegEarnCode();
            buildTimeBlockRunRules(lastClockLog, clockLog, timesheetDocument, assignment, earnCode,
                    lastClockLog.getClockDateTime(), clockLog.getClockDateTime());
        }
    }
    return builder.build();
}