List of usage examples for org.joda.time DateTime withZone
public DateTime withZone(DateTimeZone newZone)
From source file:org.jruby.CompatVersion.java
License:LGPL
protected static RubyTime s_mload(IRubyObject recv, RubyTime time, IRubyObject from) { Ruby runtime = recv.getRuntime(); DateTime dt = new DateTime(DateTimeZone.UTC); byte[] fromAsBytes = null; fromAsBytes = from.convertToString().getBytes(); if (fromAsBytes.length != 8) { throw runtime.newTypeError("marshaled time format differ"); }//from ww w .ja va 2s .co m int p = 0; int s = 0; for (int i = 0; i < 4; i++) { p |= ((int) fromAsBytes[i] & 0xFF) << (8 * i); } for (int i = 4; i < 8; i++) { s |= ((int) fromAsBytes[i] & 0xFF) << (8 * (i - 4)); } if ((p & (1 << 31)) == 0) { dt = dt.withMillis(p * 1000L + s); } else { p &= ~(1 << 31); dt = dt.withYear(((p >>> 14) & 0xFFFF) + 1900); dt = dt.withMonthOfYear(((p >>> 10) & 0xF) + 1); dt = dt.withDayOfMonth(((p >>> 5) & 0x1F)); dt = dt.withHourOfDay((p & 0x1F)); dt = dt.withMinuteOfHour(((s >>> 26) & 0x3F)); dt = dt.withSecondOfMinute(((s >>> 20) & 0x3F)); // marsaling dumps usec, not msec dt = dt.withMillisOfSecond((s & 0xFFFFF) / 1000); dt = dt.withZone(getLocalTimeZone(runtime)); time.setUSec((s & 0xFFFFF) % 1000); } time.setDateTime(dt); return time; }
From source file:org.jruby.RubyTime.java
License:LGPL
protected static RubyTime s_mload(IRubyObject recv, RubyTime time, IRubyObject from) { Ruby runtime = recv.getRuntime();/*from ww w. jav a 2 s .c o m*/ DateTime dt = new DateTime(DateTimeZone.UTC); byte[] fromAsBytes; fromAsBytes = from.convertToString().getBytes(); if (fromAsBytes.length != 8) { throw runtime.newTypeError("marshaled time format differ"); } int p = 0; int s = 0; for (int i = 0; i < 4; i++) { p |= ((int) fromAsBytes[i] & 0xFF) << (8 * i); } for (int i = 4; i < 8; i++) { s |= ((int) fromAsBytes[i] & 0xFF) << (8 * (i - 4)); } boolean utc = false; if ((p & (1 << 31)) == 0) { dt = dt.withMillis(p * 1000L); time.setUSec((s & 0xFFFFF) % 1000); } else { p &= ~(1 << 31); utc = ((p >>> 30 & 0x1) == 0x1); dt = dt.withYear(((p >>> 14) & 0xFFFF) + 1900); dt = dt.withMonthOfYear(((p >>> 10) & 0xF) + 1); dt = dt.withDayOfMonth(((p >>> 5) & 0x1F)); dt = dt.withHourOfDay((p & 0x1F)); dt = dt.withMinuteOfHour(((s >>> 26) & 0x3F)); dt = dt.withSecondOfMinute(((s >>> 20) & 0x3F)); // marsaling dumps usec, not msec dt = dt.withMillisOfSecond((s & 0xFFFFF) / 1000); time.setUSec((s & 0xFFFFF) % 1000); } time.setDateTime(dt); if (!utc) time.localtime(); from.getInstanceVariables().copyInstanceVariablesInto(time); // pull out nanos, offset, zone IRubyObject nano_num = (IRubyObject) from.getInternalVariables().getInternalVariable("nano_num"); IRubyObject nano_den = (IRubyObject) from.getInternalVariables().getInternalVariable("nano_den"); IRubyObject offsetVar = (IRubyObject) from.getInternalVariables().getInternalVariable("offset"); IRubyObject zoneVar = (IRubyObject) from.getInternalVariables().getInternalVariable("zone"); if (nano_num != null && nano_den != null) { long nanos = nano_num.convertToInteger().getLongValue() / nano_den.convertToInteger().getLongValue(); time.nsec += nanos; } int offset = 0; if (offsetVar != null && offsetVar.respondsTo("to_int")) { IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $! try { offset = offsetVar.convertToInteger().getIntValue() * 1000; } catch (RaiseException typeError) { runtime.getGlobalVariables().set("$!", oldExc); // Restore $! } } String zone = ""; if (zoneVar != null && zoneVar.respondsTo("to_str")) { IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $! try { zone = zoneVar.convertToString().toString(); } catch (RaiseException typeError) { runtime.getGlobalVariables().set("$!", oldExc); // Restore $! } } time.dt = dt.withZone(getTimeZoneWithOffset(runtime, zone, offset)); return time; }
From source file:org.jvyamlb.SafeConstructorImpl.java
public static Object constructYamlTimestamp(final Constructor ctor, final Node node) { Matcher match = YMD_REGEXP.matcher(node.getValue().toString()); if (match.matches()) { final String year_s = match.group(1); final String month_s = match.group(2); final String day_s = match.group(3); DateTime dt = new DateTime(0, 1, 1, 0, 0, 0, 0); if (year_s != null) { dt = dt.withYear(Integer.parseInt(year_s)); }/*from ww w. ja va2s . c o m*/ if (month_s != null) { dt = dt.withMonthOfYear(Integer.parseInt(month_s)); } if (day_s != null) { dt = dt.withDayOfMonth(Integer.parseInt(day_s)); } return new Object[] { dt }; } match = TIMESTAMP_REGEXP.matcher(node.getValue().toString()); if (!match.matches()) { return new Object[] { ctor.constructPrivateType(node) }; } final String year_s = match.group(1); final String month_s = match.group(2); final String day_s = match.group(3); final String hour_s = match.group(4); final String min_s = match.group(5); final String sec_s = match.group(6); final String fract_s = match.group(7); final String utc = match.group(8); final String timezoneh_s = match.group(9); final String timezonem_s = match.group(10); int usec = 0; if (fract_s != null) { usec = Integer.parseInt(fract_s); if (usec != 0) { while (10 * usec < 1000) { usec *= 10; } } } DateTime dt = new DateTime(0, 1, 1, 0, 0, 0, 0); if ("Z".equalsIgnoreCase(utc)) { dt = dt.withZone(DateTimeZone.forID("Etc/GMT")); } else { if (timezoneh_s != null || timezonem_s != null) { int zone = 0; int sign = +1; if (timezoneh_s != null) { if (timezoneh_s.startsWith("-")) { sign = -1; } zone += Integer.parseInt(timezoneh_s.substring(1)) * 3600000; } if (timezonem_s != null) { zone += Integer.parseInt(timezonem_s) * 60000; } dt = dt.withZone(DateTimeZone.forOffsetMillis(sign * zone)); } } if (year_s != null) { dt = dt.withYear(Integer.parseInt(year_s)); } if (month_s != null) { dt = dt.withMonthOfYear(Integer.parseInt(month_s)); } if (day_s != null) { dt = dt.withDayOfMonth(Integer.parseInt(day_s)); } if (hour_s != null) { dt = dt.withHourOfDay(Integer.parseInt(hour_s)); } if (min_s != null) { dt = dt.withMinuteOfHour(Integer.parseInt(min_s)); } if (sec_s != null) { dt = dt.withSecondOfMinute(Integer.parseInt(sec_s)); } dt = dt.withMillisOfSecond(usec / 1000); return new Object[] { dt, new Integer(usec % 1000) }; }
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 w w .ja v a2 s .co 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.detail.validation.TimeDetailValidationUtil.java
License:Educational Community License
public static List<String> validateOverlap(Long startTime, Long endTime, boolean acrossDays, String startDateS, String endTimeS, DateTime startTemp, DateTime endTemp, TimesheetDocument timesheetDocument, String timeblockId, boolean isRegularEarnCode) { List<String> errors = new ArrayList<String>(); Interval addedTimeblockInterval = new Interval(startTime, endTime); List<Interval> dayInt = new ArrayList<Interval>(); //if the user is clocked in, check if this time block overlaps with the clock action ClockLog lastClockLog = TkServiceLocator.getClockLogService() .getLastClockLog(HrContext.getTargetPrincipalId()); if (lastClockLog != null && (lastClockLog.getClockAction().equals(TkConstants.CLOCK_IN) || lastClockLog.getClockAction().equals(TkConstants.LUNCH_IN))) { DateTime lastClockDateTime = lastClockLog.getClockDateTime(); String lastClockZone = lastClockLog.getClockTimestampTimezone(); if (StringUtils.isEmpty(lastClockZone)) { lastClockZone = TKUtils.getSystemTimeZone(); }//from w w w . ja v a 2 s . co m DateTimeZone zone = DateTimeZone.forID(lastClockZone); DateTime clockWithZone = lastClockDateTime.withZone(zone); DateTime currentTime = new DateTime(System.currentTimeMillis(), zone); Interval currentClockInInterval = new Interval(clockWithZone.getMillis(), currentTime.getMillis()); if (isRegularEarnCode && addedTimeblockInterval.overlaps(currentClockInInterval)) { errors.add("The time block you are trying to add overlaps with the current clock action."); return errors; } } if (acrossDays) { DateTime start = new DateTime(startTime); DateTime end = TKUtils.convertDateStringToDateTime(startDateS, endTimeS); if (endTemp.getDayOfYear() - startTemp.getDayOfYear() < 1) { end = new DateTime(endTime); } DateTime groupEnd = new DateTime(endTime); Long startLong = start.getMillis(); Long endLong = end.getMillis(); //create interval span if start is before the end and the end is after the start except //for when the end is midnight ..that converts to midnight of next day DateMidnight midNight = new DateMidnight(endLong); while (start.isBefore(groupEnd.getMillis()) && ((endLong >= startLong) || end.isEqual(midNight))) { Interval tempInt = null; if (end.isEqual(midNight)) { tempInt = addedTimeblockInterval; } else { tempInt = new Interval(startLong, endLong); } dayInt.add(tempInt); start = start.plusDays(1); end = end.plusDays(1); startLong = start.getMillis(); endLong = end.getMillis(); } } else { dayInt.add(addedTimeblockInterval); } for (TimeBlock timeBlock : timesheetDocument.getTimeBlocks()) { if (errors.size() == 0 && StringUtils.equals(timeBlock.getEarnCodeType(), HrConstants.EARN_CODE_TIME)) { Interval timeBlockInterval = new Interval(timeBlock.getBeginTimestamp().getTime(), timeBlock.getEndTimestamp().getTime()); for (Interval intv : dayInt) { if (isRegularEarnCode && timeBlockInterval.overlaps(intv) && (timeblockId == null || timeblockId.compareTo(timeBlock.getTkTimeBlockId()) != 0)) { errors.add("The time block you are trying to add overlaps with an existing time block."); } } } } return errors; }
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());// w ww . ja v a 2s . co m 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(); }
From source file:org.kuali.kpme.tklm.time.missedpunch.MissedPunchServiceImpl.java
License:Educational Community License
protected MissedPunch addClockLogAndTimeBlocks(MissedPunch missedPunch, String ipAddress, String logEndId, String logBeginId) {/*from w w w.j ava 2s. c om*/ 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()); Assignment assignment = HrServiceLocator.getAssignmentService().getAssignment(missedPunch.getPrincipalId(), assignmentDescriptionKey, missedPunch.getActionLocalDate()); CalendarEntry calendarEntry = timesheetDocument.getCalendarEntry(); String dateString = TKUtils.formatDateTimeShort(missedPunch.getActionFullDateTime()); String longDateString = TKUtils.formatDateTimeLong(missedPunch.getActionFullDateTime()); String timeString = TKUtils.formatTimeShort(longDateString); String userTimezone = HrServiceLocator.getTimezoneService().getUserTimezone(missedPunch.getPrincipalId()); DateTimeZone userTimeZone = DateTimeZone.forID(userTimezone); DateTime dateTimeWithUserZone = TKUtils.convertDateStringToDateTimeWithTimeZone(dateString, timeString, userTimeZone); DateTime userActionDateTime = missedPunch.getActionFullDateTime(); 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); clockLogService.saveClockLog(clockLog); builder.setActionFullDateTime(missedPunch.getActionFullDateTime()); builder.setTkClockLogId(clockLog.getTkClockLogId()); if (logEndId != null || logBeginId != null) { ClockLog endLog; ClockLog beginLog; if (logEndId != null) { endLog = clockLogService.getClockLog(logEndId); } else { endLog = clockLog; } if (logBeginId != null) { beginLog = clockLogService.getClockLog(logBeginId); } else { beginLog = clockLog; } if (beginLog != null && endLog != null && beginLog.getClockDateTime().isBefore(endLog.getClockDateTime())) { String earnCode = assignment.getJob().getPayTypeObj().getRegEarnCode(); buildTimeBlockRunRules(beginLog, endLog, timesheetDocument, assignment, earnCode, beginLog.getClockDateTime(), endLog.getClockDateTime()); } } return builder.build(); }
From source file:org.kuali.kpme.tklm.time.timeblock.service.TimeBlockServiceImpl.java
License:Educational Community License
public List<TimeBlock> buildTimeBlocksSpanDates(Assignment assignment, String earnCode, TimesheetDocument timesheetDocument, DateTime beginDateTime, DateTime endDateTime, BigDecimal hours, BigDecimal amount, Boolean getClockLogCreated, Boolean getLunchDeleted, String spanningWeeks, String userPrincipalId) { DateTimeZone zone = HrServiceLocator.getTimezoneService().getUserTimezoneWithFallback(); DateTime beginDt = beginDateTime.withZone(zone); DateTime endDt = beginDt.toLocalDate().toDateTime(endDateTime.withZone(zone).toLocalTime(), zone); if (endDt.isBefore(beginDt)) endDt = endDt.plusDays(1);/* w w w . j a v a 2 s. co m*/ List<Interval> dayInt = TKUtils.getDaySpanForCalendarEntry(timesheetDocument.getCalendarEntry()); TimeBlock firstTimeBlock = new TimeBlock(); List<TimeBlock> lstTimeBlocks = new ArrayList<TimeBlock>(); DateTime endOfFirstDay = null; // KPME-2568 long diffInMillis = 0; // KPME-2568 for (Interval dayIn : dayInt) { if (dayIn.contains(beginDt)) { if (dayIn.contains(endDt) || dayIn.getEnd().equals(endDt)) { // KPME-1446 if "Include weekends" check box is checked, don't add Sat and Sun to the timeblock list if (StringUtils.isEmpty(spanningWeeks) && (dayIn.getStart().getDayOfWeek() == DateTimeConstants.SATURDAY || dayIn.getStart().getDayOfWeek() == DateTimeConstants.SUNDAY)) { // Get difference in millis for the next time block - KPME-2568 endOfFirstDay = endDt.withZone(zone); diffInMillis = endOfFirstDay.minus(beginDt.getMillis()).getMillis(); } else { firstTimeBlock = createTimeBlock(timesheetDocument, beginDateTime, endDt, assignment, earnCode, hours, amount, false, getLunchDeleted, userPrincipalId); lstTimeBlocks.add(firstTimeBlock); } } else { //TODO move this to prerule validation //throw validation error if this case met error } } } DateTime endTime = endDateTime.withZone(zone); if (firstTimeBlock.getEndDateTime() != null) { // KPME-2568 endOfFirstDay = firstTimeBlock.getEndDateTime().withZone(zone); diffInMillis = endOfFirstDay.minus(beginDt.getMillis()).getMillis(); } DateTime currTime = beginDt.plusDays(1); while (currTime.isBefore(endTime) || currTime.isEqual(endTime)) { // KPME-1446 if "Include weekends" check box is checked, don't add Sat and Sun to the timeblock list if (StringUtils.isEmpty(spanningWeeks) && (currTime.getDayOfWeek() == DateTimeConstants.SATURDAY || currTime.getDayOfWeek() == DateTimeConstants.SUNDAY)) { // do nothing } else { TimeBlock tb = createTimeBlock(timesheetDocument, currTime, currTime.plus(diffInMillis), assignment, earnCode, hours, amount, false, getLunchDeleted, userPrincipalId); lstTimeBlocks.add(tb); } currTime = currTime.plusDays(1); } return lstTimeBlocks; }
From source file:org.modeshape.graph.property.basic.JodaDateTime.java
License:Open Source License
/** * {@inheritDoc}//from w w w . ja v a 2s . co m */ @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof org.modeshape.graph.property.DateTime) { org.modeshape.graph.property.DateTime that = (org.modeshape.graph.property.DateTime) obj; return this.getMillisecondsInUtc() == that.getMillisecondsInUtc(); } if (obj instanceof DateTime) { DateTime that = (DateTime) obj; return this.getMillisecondsInUtc() == that.withZone(UTC_ZONE).getMillis(); } return false; }
From source file:org.modeshape.jcr.value.basic.JodaDateTime.java
License:Apache License
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof org.modeshape.jcr.api.value.DateTime) { org.modeshape.jcr.api.value.DateTime that = (org.modeshape.jcr.api.value.DateTime) obj; return this.getMillisecondsInUtc() == that.getMillisecondsInUtc(); }//from w w w .ja v a 2s. c o m if (obj instanceof DateTime) { DateTime that = (DateTime) obj; return this.getMillisecondsInUtc() == that.withZone(UTC_ZONE).getMillis(); } return false; }