下面列出了org.joda.time.LocalDate#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private int diff360EIsda(final LocalDate start, final LocalDate end) {
if (start.equals(end)) {
return 0;
}
int dayStart = start.getDayOfMonth();
int dayEnd = end.getDayOfMonth();
if (start.dayOfMonth().getMaximumValue() == dayStart) {
dayStart = CalculatorConstants.MONTH_30_DAYS;
}
if (end.getMonthOfYear() != 2 && end.dayOfMonth().getMaximumValue() == dayEnd) {
dayEnd = CalculatorConstants.MONTH_30_DAYS;
}
return (end.getYear() - start.getYear()) * CalculatorConstants.YEAR_360 + (end.getMonthOfYear() - start.getMonthOfYear()) * CalculatorConstants.MONTH_30_DAYS + dayEnd - dayStart;
}
public ActionForward search(ActionMapping mapping, HttpServletRequest request, final LocalDate day, final LocalTime begin,
final LocalTime end, DynaActionForm dynaActionForm) throws Exception {
Integer totalOfStudents = 0;
final Set<WrittenEvaluation> writtenEvaluations = new HashSet<WrittenEvaluation>();
for (final ExecutionCourse executionCourse : getExecutionCoursesActiveIn(day)) {
for (final Evaluation evaluation : executionCourse.getAssociatedEvaluationsSet()) {
if (evaluation instanceof WrittenEvaluation) {
final WrittenEvaluation writtenEvaluation = (WrittenEvaluation) evaluation;
final LocalDate evaluationDate = writtenEvaluation.getDayDateYearMonthDay().toLocalDate();
if (evaluationDate != null && evaluationDate.equals(day) && isEvalBetweenDates(writtenEvaluation, begin, end)) {
if (!writtenEvaluations.contains(writtenEvaluation)) {
totalOfStudents += writtenEvaluation.getCountStudentsEnroledAttendingExecutionCourses();
}
writtenEvaluations.add(writtenEvaluation);
}
}
}
}
request.setAttribute(
"availableRoomIndicationMsg",
BundleUtil.getString(Bundle.RESOURCE_ALLOCATION, "info.total.students.vs.available.seats",
totalOfStudents.toString(), SpaceUtils.countAllAvailableSeatsForExams().toString()));
request.setAttribute("writtenEvaluations", writtenEvaluations);
return mapping.findForward("show");
}
@Programmatic
public TaxRate newRate(
final Tax tax,
final LocalDate startDate,
final BigDecimal percentage) {
TaxRate currentRate = tax.taxRateFor(startDate);
TaxRate rate;
if (currentRate == null || !startDate.equals(currentRate.getStartDate())) {
rate = repositoryService.instantiate(TaxRate.class);
rate.setTax(tax);
rate.setStartDate(startDate);
if(repositoryService.isPersistent(tax)) {
repositoryService.persist(rate);
}
} else {
rate = currentRate;
}
rate.setPercentage(percentage);
if (currentRate != null) {
TaxRate currentNextRate = currentRate.getNext();
currentRate.modifyNext(rate);
rate.modifyNext(currentNextRate);
}
return rate;
}
/**
* Checks if a given date is an official IMM Date (3rd Wednesdays of
* March/June/Sept/Dec.
*
* @param date
* @return true if that date is an IMM date.
*/
@Override
public boolean isIMMDate(final LocalDate date) {
boolean same = false;
final List<LocalDate> dates = getIMMDates(date.minusDays(1), date, QUARTERLY);
if (!dates.isEmpty()) {
same = date.equals(dates.get(0));
}
return same;
}
public boolean contains(LocalDate date) {
LocalDate start = new LocalDate(date.getYear(), getMonthStart(), getDayStart());
LocalDate end = new LocalDate(date.getYear(), getMonthEnd(), getDayEnd());
if ((date.equals(start) || date.isAfter(start)) && (date.equals(end) || date.isBefore(end))) {
return true;
} else {
return false;
}
}
@Programmatic
public LeaseTerm findTerm(final LocalDate startDate) {
for (LeaseTerm term : getTerms()) {
if (startDate.equals(term.getStartDate())) {
return term;
}
}
return null;
}
@Override
public void onReceive(@NotNull Context context, @NotNull Intent intent) {
String action = intent.getAction();
if (intent.getExtras() == null)
return;
final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
final DilbertPreferences preferences = new DilbertPreferences(context);
if (action == null || appWidgetId == -1) {
super.onReceive(context, intent);
return;
}
if (currentToast != null)
currentToast.cancel();
switch (action) {
case INTENT_PREVIOUS:
preferences.saveDateForWidgetId(appWidgetId, preferences
.getDateForWidgetId(appWidgetId).minusDays(1));
break;
case INTENT_NEXT:
preferences.saveDateForWidgetId(appWidgetId, preferences
.getDateForWidgetId(appWidgetId).plusDays(1));
break;
case INTENT_LATEST:
preferences.saveDateForWidgetId(appWidgetId,
LocalDate.now());
break;
case INTENT_RANDOM:
preferences.saveDateForWidgetId(appWidgetId,
DilbertPreferences.getRandomDate());
break;
case INTENT_REFRESH:
preferences
.removeCache(preferences.getDateForWidgetId(appWidgetId));
break;
case INTENT_DISPLAY:
preferences.saveCurrentDate(preferences
.getDateForWidgetId(appWidgetId));
Intent display = new Intent(context, DilbertFragmentActivity.class);
display.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(display);
break;
case AppWidgetManager.ACTION_APPWIDGET_UPDATE:
LocalDate current = preferences.getDateForWidgetId(appWidgetId);
if (current.equals(LocalDate.now()
.minusDays(1))) {
preferences.saveDateForWidgetId(appWidgetId,
LocalDate.now());
}
break;
}
updateAppWidget(context, AppWidgetManager.getInstance(context),
appWidgetId);
if (currentToast != null)
currentToast.show();
super.onReceive(context, intent);
}