List of usage examples for org.joda.time DateTimeZone forID
@FromString public static DateTimeZone forID(String id)
From source file:org.kuali.kpme.tklm.time.missedpunch.MissedPunchServiceImpl.java
License:Educational Community License
@Override public MissedPunch updateClockLog(MissedPunch missedPunch, String ipAddress) { DateTime actionDateTime = missedPunch.getActionFullDateTime(); ClockLog clockLog = clockLogService.getClockLog(missedPunch.getTkClockLogId()); if (clockLog != null) { DateTime clockDtInUserTimeZone = clockLog.getClockDateTime() .withZone(DateTimeZone.forID(clockLog.getClockTimestampTimezone())); if (!clockDtInUserTimeZone.equals(actionDateTime)) { String clockLogEndId = null; String clockLogBeginId = null; List<TimeBlock> timeBlocks = timeBlockService .getTimeBlocksForClockLogEndId(clockLog.getTkClockLogId()); if (timeBlocks.isEmpty()) { timeBlocks = timeBlockService.getTimeBlocksForClockLogBeginId(clockLog.getTkClockLogId()); if (!timeBlocks.isEmpty()) { clockLogEndId = timeBlocks.get(0).getClockLogEndId(); }/*from w w w .j a v a2 s .c om*/ } else { clockLogBeginId = timeBlocks.get(0).getClockLogBeginId(); } deleteClockLogAndTimeBlocks(clockLog, timeBlocks); missedPunch = addClockLogAndTimeBlocks(missedPunch, ipAddress, clockLogEndId, clockLogBeginId); } } return missedPunch; }
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 av a 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.rules.TkRuleControllerServiceImpl.java
License:Educational Community License
public List<TimeBlock> applyRules(String action, List<TimeBlock> timeBlocks, List<LeaveBlock> leaveBlocks, CalendarEntry payEntry, TimesheetDocument timesheetDocument, String principalId) { //foreach action run the rules that apply if (StringUtils.equals(action, TkConstants.ACTIONS.ADD_TIME_BLOCK) || StringUtils.equals(action, TkConstants.ACTIONS.CLOCK_OUT)) { List<TimeBlock> updatedTimeBlocks = new ArrayList<TimeBlock>(); Calendar calendar = HrServiceLocator.getCalendarService().getCalendar(payEntry.getHrCalendarId()); DateTimeZone userTimeZone = DateTimeZone.forID( HrServiceLocator.getTimezoneService().getUserTimezone(timesheetDocument.getPrincipalId())); if (userTimeZone == null) userTimeZone = HrServiceLocator.getTimezoneService().getTargetUserTimezoneWithFallback(); List<Interval> dayIntervals = TKUtils.getDaySpanForCalendarEntry(payEntry, userTimeZone); TkTimeBlockAggregate timeBlockAggregate = new TkTimeBlockAggregate(timeBlocks, leaveBlocks, payEntry, calendar, true, dayIntervals); ///* ww w . jav a2s . c om*/ // Need to run LunchRule first - It will reduce hours in some instances // anyone who records time through the time entry form (async users) should not be affected by the lunch rule // Noted that the date field in the buildTkUser method is not currently used. List<TimeBlock> lunchBlocks = new ArrayList<TimeBlock>(); if (GlobalVariables.getUserSession() != null && TkContext.isTargetSynchronous()) { lunchBlocks = TkServiceLocator.getDepartmentLunchRuleService() .applyDepartmentLunchRule(timeBlockAggregate.getFlattenedTimeBlockList()); //update aggregate with lunch blocks :( ---- HACK!!! until we can stop passing everything through this aggregate!!!! TkTimeBlockAggregate tempAggregate = new TkTimeBlockAggregate(lunchBlocks, timeBlockAggregate.getPayCalendarEntry(), timeBlockAggregate.getPayCalendar(), true); timeBlockAggregate.setDayTimeBlockList(tempAggregate.getDayTimeBlockList()); } TkServiceLocator.getShiftDifferentialRuleService().processShiftDifferentialRules(timesheetDocument, timeBlockAggregate); TkServiceLocator.getDailyOvertimeRuleService().processDailyOvertimeRules(timesheetDocument, timeBlockAggregate); TkServiceLocator.getWeeklyOvertimeRuleService().processWeeklyOvertimeRule(timesheetDocument, timeBlockAggregate); // check for Premium holiday Earncode return TkServiceLocator.getTimeBlockService().applyHolidayPremiumEarnCode( timesheetDocument.getPrincipalId(), timesheetDocument.getAllAssignments(), timeBlockAggregate.getFlattenedTimeBlockList()); } return timeBlocks; }
From source file:org.kuali.kpme.tklm.utils.TkTestUtils.java
License:Educational Community License
/** * Helper method to verify that the aggregate contains the correct sums as * indicated in the ecToHoursMapping, on a SINGLE given flsaWeek. * * Warning! Contains Assertions, use only with Test Cases. * * @param ecToHoursMap ex: { 'REG' => 40, 'OVT' => 10 } * @param aggregate An aggregate object containing the time blocks * @param flsaWeek 0 indexed start week (pulling from aggregate) */// w w w.ja va2 s . c o m @SuppressWarnings("serial") public static void verifyAggregateHourSums(String msg, final Map<String, BigDecimal> ecToHoursMap, TkTimeBlockAggregate aggregate, int flsaWeek) { // Initializes sum map to zeros, since we only care about the entires // that were passed in. Map<String, BigDecimal> ecToSumMap = new HashMap<String, BigDecimal>() { { for (String ec : ecToHoursMap.keySet()) { put(ec, BigDecimal.ZERO); } } }; List<FlsaWeek> flsaWeeks = aggregate.getFlsaWeeks(DateTimeZone.forID(TKUtils.getSystemTimeZone())); Assert.assertTrue( msg + " >> Not enough FLSA weeks to verify aggregate hours, max: " + (flsaWeeks.size() - 1), flsaWeeks.size() > flsaWeek); // Build our Sum Map. FlsaWeek week = flsaWeeks.get(flsaWeek); List<FlsaDay> flsaDays = week.getFlsaDays(); for (FlsaDay day : flsaDays) { for (TimeBlock bl : day.getAppliedTimeBlocks()) { for (TimeHourDetail thd : bl.getTimeHourDetails()) { if (ecToSumMap.containsKey(thd.getEarnCode())) { ecToSumMap.put(thd.getEarnCode(), ecToSumMap.get(thd.getEarnCode()).add(thd.getHours())); } } } } // Assert that our values are correct. for (String key : ecToHoursMap.keySet()) { Assert.assertEquals( msg + " >> (" + key + ") Wrong number of hours expected: " + ecToHoursMap.get(key) + " found: " + ecToSumMap.get(key) + " :: ", 0, ecToHoursMap.get(key).compareTo(ecToSumMap.get(key))); } }
From source file:org.locationtech.geomesa.examples.KafkaQuickStart.java
License:Open Source License
public static void addSimpleFeatures(SimpleFeatureType sft, FeatureStore producerFS) throws InterruptedException, IOException { final int MIN_X = -180; final int MAX_X = 180; final int MIN_Y = -90; final int MAX_Y = 90; final int DX = 2; final int DY = 1; final String[] PEOPLE_NAMES = { "James", "John", "Peter", "Hannah", "Claire", "Gabriel" }; final long SECONDS_PER_YEAR = 365L * 24L * 60L * 60L; final Random random = new Random(); final DateTime MIN_DATE = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeZone.forID("UTC")); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(sft); DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(); // creates and updates two SimpleFeatures. // the first time this for loop runs the two SimpleFeatures are created. // in the subsequent iterations of the for loop, the two SimpleFeatures are updated. int numFeatures = (MAX_X - MIN_X) / DX; for (int i = 1; i <= numFeatures; i++) { builder.add(PEOPLE_NAMES[i % PEOPLE_NAMES.length]); // name builder.add((int) Math.round(random.nextDouble() * 110)); // age builder.add(MIN_DATE.plusSeconds((int) Math.round(random.nextDouble() * SECONDS_PER_YEAR)).toDate()); // dtg builder.add(WKTUtils$.MODULE$.read("POINT(" + (MIN_X + DX * i) + " " + (MIN_Y + DY * i) + ")")); // geom SimpleFeature feature1 = builder.buildFeature("1"); builder.add(PEOPLE_NAMES[(i + 1) % PEOPLE_NAMES.length]); // name builder.add((int) Math.round(random.nextDouble() * 110)); // age builder.add(MIN_DATE.plusSeconds((int) Math.round(random.nextDouble() * SECONDS_PER_YEAR)).toDate()); // dtg builder.add(WKTUtils$.MODULE$.read("POINT(" + (MIN_X + DX * i) + " " + (MAX_Y - DY * i) + ")")); // geom SimpleFeature feature2 = builder.buildFeature("2"); // write the SimpleFeatures to Kafka featureCollection.add(feature1); featureCollection.add(feature2); producerFS.addFeatures(featureCollection); featureCollection.clear();//w ww.j a v a2 s .c o m // wait 200 ms in between updating SimpleFeatures to simulate a stream of data Thread.sleep(200); } }
From source file:org.logstash.filters.parser.CasualISO8601Parser.java
License:Apache License
public CasualISO8601Parser(String timeZone) { this.timeZone = timeZone; if (timeZone == null) { parsers = baseParsers;/*from w w w .j a v a 2s. c om*/ } else { parsers = Arrays.stream(baseParsers).map(p -> p.withZone(DateTimeZone.forID(timeZone))) .toArray(DateTimeFormatter[]::new); } }
From source file:org.logstash.filters.parser.JodaParser.java
License:Apache License
public JodaParser(String pattern, Locale locale, String timezone) { this.timezone = timezone; // Does the pattern contain year information? hasYear = (pattern.contains("Y") || pattern.contains("y")); // If pattern has no timezone format, we should parse in "local" time. hasZone = pattern.contains("Z"); parser = DateTimeFormat.forPattern(pattern).withLocale(locale).withZone(DateTimeZone.forID(timezone)); }
From source file:org.logstash.filters.parser.JodaParser.java
License:Apache License
@Override public Instant parseWithTimeZone(String value, String timezone) { DateTimeZone tz = DateTimeZone.forID(timezone); DateTimeFormatter parserWithZone = parser.withZone(tz); if (hasYear) { return new Instant(parserWithZone.parseMillis(value)); } else {/*from w w w .j a v a 2 s . com*/ return parseAndGuessYear(parserWithZone, value); } }
From source file:org.mifosplatform.infrastructure.core.service.DateUtils.java
License:Mozilla Public License
public static DateTimeZone getDateTimeZoneOfTenant() { final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); DateTimeZone zone = null;//from ww w. j a va2 s. c o m if (tenant != null) { zone = DateTimeZone.forID(tenant.getTimezoneId()); TimeZone.getTimeZone(tenant.getTimezoneId()); } return zone; }
From source file:org.mifosplatform.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Mozilla Public License
private LocalDateTime tenantDateTime() { LocalDateTime today = new LocalDateTime(); final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant(); if (tenant != null) { final DateTimeZone zone = DateTimeZone.forID(tenant.getTimezoneId()); if (zone != null) { today = new LocalDateTime(zone); }/*from w ww .ja va 2 s .c om*/ } return today; }