List of usage examples for org.joda.time LocalDateTime get
public int get(DateTimeFieldType type)
From source file:de.avanux.smartapplianceenabler.appliance.TimeOfDay.java
License:Open Source License
public TimeOfDay(LocalDateTime dateTime) { hour = dateTime.get(DateTimeFieldType.hourOfDay()); minute = dateTime.get(DateTimeFieldType.minuteOfHour()); second = dateTime.get(DateTimeFieldType.secondOfMinute()); }
From source file:de.avanux.smartapplianceenabler.appliance.TimeOfDayOfWeek.java
License:Open Source License
public LocalDateTime toNextOccurrence(LocalDateTime now) { LocalDateTime dateTime = new LocalDateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), getHour(), getMinute(), getSecond()); while (dateTime.get(DateTimeFieldType.dayOfWeek()) != dayOfWeek) { dateTime = dateTime.plusDays(1); }//w w w . j av a 2s. c om return dateTime; }
From source file:de.avanux.smartapplianceenabler.appliance.TimeOfDayOfWeek.java
License:Open Source License
public LocalDateTime toLastOccurrence(LocalDateTime now) { LocalDateTime dateTime = new LocalDateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), getHour(), getMinute(), getSecond()); while (dateTime.get(DateTimeFieldType.dayOfWeek()) != dayOfWeek) { dateTime = dateTime.minusDays(1); }/*from w w w .ja v a2s .c o m*/ return dateTime; }
From source file:org.kuali.kpme.tklm.time.timesummary.service.TimeSummaryServiceImpl.java
License:Educational Community License
/** * Generate a list of string describing this pay calendar entry for the summary * @param payCalEntry//ww w.j ava 2s. c o m * @return */ protected List<String> getSummaryHeader(CalendarEntry payCalEntry) { List<String> summaryHeader = new ArrayList<String>(); int dayCount = 0; DateTime beginDateTime = payCalEntry.getBeginPeriodFullDateTime(); DateTime endDateTime = payCalEntry.getEndPeriodFullDateTime(); boolean virtualDays = false; LocalDateTime endDate = payCalEntry.getEndPeriodLocalDateTime(); if (endDate.get(DateTimeFieldType.hourOfDay()) != 0 || endDate.get(DateTimeFieldType.minuteOfHour()) != 0 || endDate.get(DateTimeFieldType.secondOfMinute()) != 0) { virtualDays = true; } DateTime currentDateTime = beginDateTime; while (currentDateTime.isBefore(endDateTime)) { LocalDateTime currDate = currentDateTime.toLocalDateTime(); summaryHeader.add(makeHeaderDiplayString(currDate, virtualDays)); dayCount++; if ((dayCount % 7) == 0) { summaryHeader.add("Week " + ((dayCount / 7))); } currentDateTime = currentDateTime.plusDays(1); } summaryHeader.add("Period Total"); return summaryHeader; }
From source file:org.kuali.kpme.tklm.time.timesummary.service.TimeSummaryServiceImpl.java
License:Educational Community License
/** * Handles the generation of the display header for the time summary. * * @param cal The PayCalendarEntries object we are using to derive information. * @param dayArrangements Container passed in to store the position of week / period aggregate sums * * @return An in-order string of days for this period that properly accounts * for FLSA week boundaries in the pay period. *///from w w w . j ava2 s .c om @Override public List<String> getHeaderForSummary(CalendarEntry cal, List<Boolean> dayArrangements) { List<String> header = new ArrayList<String>(); if (cal == null) { return Collections.emptyList(); } // Maps directly to joda time day of week constants. int flsaBeginDay = this.getPayCalendarForEntry(cal).getFlsaBeginDayConstant(); boolean virtualDays = false; LocalDateTime startDate = cal.getBeginPeriodLocalDateTime(); LocalDateTime endDate = cal.getEndPeriodLocalDateTime(); // Increment end date if we are on a virtual day calendar, so that the // for loop can account for having the proper amount of days on the // summary calendar. if (endDate.get(DateTimeFieldType.hourOfDay()) != 0 || endDate.get(DateTimeFieldType.minuteOfHour()) != 0 || endDate.get(DateTimeFieldType.secondOfMinute()) != 0) { endDate = endDate.plusDays(1); virtualDays = true; } boolean afterFirstDay = false; int week = 1; for (LocalDateTime currentDate = startDate; currentDate.compareTo(endDate) < 0; currentDate = currentDate .plusDays(1)) { if (currentDate.getDayOfWeek() == flsaBeginDay && afterFirstDay) { header.add("Week " + week); dayArrangements.add(false); week++; } header.add(makeHeaderDiplayString(currentDate, virtualDays)); dayArrangements.add(true); afterFirstDay = true; } // We may have a very small final "week" on this pay period. For now // we will mark it as a week, and if someone doesn't like it, it can // be removed. if (!header.isEmpty() && !header.get(header.size() - 1).startsWith("Week")) { dayArrangements.add(false); header.add("Week " + week); } header.add("Period Total"); dayArrangements.add(false); return header; }
From source file:org.netxilia.api.utils.DateUtils.java
License:Open Source License
public static int getField(ReadablePartial partial, LocalDateTime fullDateTime, DateTimeFieldType field) { return partial.isSupported(field) ? partial.get(field) : fullDateTime.get(field); }