List of usage examples for org.joda.time LocalDate equals
public boolean equals(Object partial)
From source file:graphene.util.time.JodaTimeUtil.java
License:Apache License
public static void test_localDate_shift_java_tz() { System.out.println("Test LocalDate with shifted Java timezone"); final TimeZone originalTZ = TimeZone.getDefault(); final TimeZone losAngelesTZ = TimeZone.getTimeZone("America/Los_Angeles"); TimeZone.setDefault(losAngelesTZ); final LocalDate ld1 = new LocalDate(); System.out.println("ld1 LocalDate() = " + ld1 + " when default TZ = " + TimeZone.getDefault()); final java.sql.Date d = toSQLDate(ld1); System.out.println("d toSQLDate(ld1) = " + d + " when default TZ = " + TimeZone.getDefault()); TimeZone.setDefault(originalTZ); System.out.println("d toSQLDate(ld1) = " + d + " when default TZ = " + TimeZone.getDefault()); final LocalDate ld2 = toLocalDate(d); System.out.println("ld2 toLocalDate(d) = " + ld2 + " when default TZ = " + TimeZone.getDefault()); TimeZone.setDefault(originalTZ); if (!ld2.equals(ld1)) { throw new IllegalStateException(); }/* w ww .j a v a2 s. c o m*/ }
From source file:graphene.util.time.JodaTimeUtil.java
License:Apache License
public static void test_localDate_shift_joda_tz() { System.out.println("Test LocalDate with shifted JodaTime timezone"); final DateTimeZone originalTZ = DateTimeZone.getDefault(); final DateTimeZone losAngelesTZ = DateTimeZone.forID("America/Los_Angeles"); DateTimeZone.setDefault(losAngelesTZ); final LocalDate ld0 = new LocalDate(losAngelesTZ); System.out.println(/*from w ww . j av a 2 s.c o m*/ "ld0 LocalDate(losAngelesTZ) = " + ld0 + " when default TZ = " + DateTimeZone.getDefault()); DateTimeZone.setDefault(losAngelesTZ); final LocalDate ld1 = new LocalDate(); System.out.println( "ld1 LocalDate() = " + ld1 + " when default TZ = " + DateTimeZone.getDefault()); final java.sql.Date d0 = toSQLDate(ld1); System.out .println("d0 toSQLDate(ld0) = " + d0 + " when default TZ = " + DateTimeZone.getDefault()); final java.sql.Date d1 = toSQLDate(ld1); System.out .println("d1 toSQLDate(ld1) = " + d1 + " when default TZ = " + DateTimeZone.getDefault()); DateTimeZone.setDefault(originalTZ); System.out .println("d1 toSQLDate(ld1) = " + d1 + " when default TZ = " + DateTimeZone.getDefault()); DateTimeZone.setDefault(originalTZ); final LocalDate ld2 = toLocalDate(d1); System.out.println( "ld2 toLocalDate(d1) = " + ld2 + " when default TZ = " + DateTimeZone.getDefault()); DateTimeZone.setDefault(originalTZ); if (!ld2.equals(ld1)) { throw new IllegalStateException(); } }
From source file:me.vertretungsplan.parser.DaVinciParser.java
License:Mozilla Public License
static void parseDaVinciTable(Element table, SubstitutionSchedule v, String klasse, SubstitutionScheduleDay day, ColorProvider colorProvider) throws IOException { boolean skipRow = false; List<String> headers = new ArrayList<>(); for (Element header : table.select("thead tr th")) { headers.add(header.text());/*from www . j ava2 s. co m*/ } if (headers.size() == 0) { skipRow = true; for (Element header : table.select(" tr:first-child td")) { headers.add(header.text()); } } // These three variables can Set<String> classes = new HashSet<>(); String lesson = null; LocalDate currentDate = null; Pattern previousCurrentPattern = Pattern.compile("\\+([^\\s]+) \\(([^)]+)\\)"); Pattern previousPattern = Pattern.compile("\\(([^)]+)\\)"); for (Element row : table.select("tr:not(thead tr)")) { if (skipRow) { skipRow = false; continue; } Substitution subst = new Substitution(); LocalDate substDate = null; Elements columns = row.select("td"); for (int i = 0; i < headers.size(); i++) { String value = columns.get(i).text().replace("\u00a0", ""); String header = headers.get(i); if (value.isEmpty()) { if (header.equals("Klasse")) subst.setClasses(new HashSet<>(classes)); if (header.equals("Pos") || header.equals("Stunde") || header.equals("Std.") || header.equals("Dstd.") || header.equals("UE")) { subst.setLesson(lesson); } if (header.equals("Art") || header.equals("Merkmal")) subst.setType("Vertretung"); if (header.equals("Datum")) substDate = currentDate; continue; } Matcher previousCurrentMatcher = previousCurrentPattern.matcher(value); Matcher previousMatcher = previousPattern.matcher(value); switch (header) { case "Klasse": String classesStr = value; if (previousMatcher.find()) { classesStr = previousMatcher.group(1); } classes = new HashSet<>(Arrays.asList(classesStr.split(", "))); subst.setClasses(classes); break; case "Pos": case "Stunde": case "Std.": case "Dstd.": case "UE": lesson = value; subst.setLesson(lesson); break; case "VLehrer": case "VLehrer Krzel": case "VLehrer Name": case "Vertreter": case "Vertretungslehrkraft": if (!value.startsWith("*")) { subst.setTeacher(value); } else { subst.setType(value.substring(1)); } break; case "Lehrer": case "Lehrer Krzel": case "Lehrer Name": case "Lehrkraft": if (previousCurrentMatcher.find()) { subst.setTeacher(previousCurrentMatcher.group(1)); subst.setPreviousTeacher(previousCurrentMatcher.group(2)); } else if (previousMatcher.find()) { subst.setPreviousTeacher(previousMatcher.group(1)); } else { subst.setPreviousTeacher(value); } break; case "VFach": case "V Fach": subst.setSubject(value); break; case "Fach": case "Original Fach": if (previousCurrentMatcher.find()) { subst.setSubject(previousCurrentMatcher.group(1)); subst.setPreviousSubject(previousCurrentMatcher.group(2)); } else { subst.setPreviousSubject(value); } break; case "VRaum": case "V Raum": case "Vertretungs Raum": subst.setRoom(value); break; case "Raum": case "Original Raum": if (previousCurrentMatcher.find()) { subst.setRoom(previousCurrentMatcher.group(1)); subst.setPreviousRoom(previousCurrentMatcher.group(2)); } else { subst.setPreviousRoom(value); } break; case "Art": case "Merkmal": case "Information": subst.setType(value); break; case "Info": case "Mitteilung": case "Bemerkung": subst.setDesc(value); break; case "Datum": substDate = ParserUtils.parseDate(value); currentDate = substDate; break; } } if (klasse != null) { Set<String> fixedClasses = new HashSet<>(); fixedClasses.add(klasse); subst.setClasses(fixedClasses); } if (subst.getType() == null) { String recognizedType = null; if (subst.getDesc() != null) recognizedType = recognizeType(subst.getDesc()); subst.setType(recognizedType != null ? recognizedType : "Vertretung"); } subst.setColor(colorProvider.getColor(subst.getType())); if (substDate == null && day == null) continue; if (day == null || substDate != null && !substDate.equals(day.getDate())) { day = null; for (SubstitutionScheduleDay d : v.getDays()) { if (d.getDate().equals(substDate)) { day = d; } } if (day == null) { day = new SubstitutionScheduleDay(); day.setDate(substDate); v.addDay(day); } } day.addSubstitution(subst); } }
From source file:module.organization.domain.AccountabilityVersion.java
License:Open Source License
private static boolean matchingDates(LocalDate date1, LocalDate date2) { if (date1 == null) { return date2 == null; }/*from ww w . j a va2s . co m*/ return date1.equals(date2); }
From source file:net.objectlab.kit.datecalc.joda.LocalDateIMMDateCalculator.java
License:Apache License
/** * Checks if a given date is an official IMM Date (3rd Wednesdays of * March/June/Sept/Dec./*from w ww .j a va 2 s . c om*/ * * @param date * @return true if that date is an IMM date. */ 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; }
From source file:net.objectlab.kit.datecalc.joda.LocalDatePeriodCountCalculator.java
License:Apache License
private int diff360EIsda(final LocalDate start, final LocalDate end) { if (start.equals(end)) { return 0; }//from w w w . j a v a 2 s. co m int dayStart = start.getDayOfMonth(); int dayEnd = end.getDayOfMonth(); if (start.dayOfMonth().getMaximumValue() == dayStart) { dayStart = MONTH_30_DAYS; } if (end.getMonthOfYear() != 2 && end.dayOfMonth().getMaximumValue() == dayEnd) { dayEnd = MONTH_30_DAYS; } return (end.getYear() - start.getYear()) * YEAR_360 + (end.getMonthOfYear() - start.getMonthOfYear()) * MONTH_30_DAYS + dayEnd - dayStart; }
From source file:net.sourceforge.fenixedu.domain.phd.debts.PhdGratuityPaymentPeriod.java
License:Open Source License
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 {// w ww. j ava 2 s . c o m return false; } }
From source file:net.sourceforge.fenixedu.domain.Teacher.java
License:Open Source License
private List<Interval> getNotOverlapedIntervals(Interval overlapInterval, Interval notYetOverlapedInterval) { List<Interval> intervals = new ArrayList<Interval>(); LocalDate overlapIntervalStart = overlapInterval.getStart().toLocalDate(); LocalDate overlapIntervalEnd = overlapInterval.getEnd().toLocalDate(); LocalDate notYetOverlapedIntervalStart = notYetOverlapedInterval.getStart().toLocalDate(); LocalDate notYetOverlapedIntervalEnd = notYetOverlapedInterval.getEnd().toLocalDate(); if (overlapIntervalStart.equals(notYetOverlapedIntervalStart) && !overlapIntervalEnd.equals(notYetOverlapedIntervalEnd)) { intervals.add(new Interval(overlapInterval.getEnd().plusDays(1), notYetOverlapedInterval.getEnd())); } else if (!overlapIntervalStart.equals(notYetOverlapedIntervalStart) && overlapIntervalEnd.equals(notYetOverlapedIntervalEnd)) { intervals/* w w w .ja v a 2 s . c o m*/ .add(new Interval(notYetOverlapedInterval.getStart(), overlapInterval.getStart().minusDays(1))); } else if (!overlapIntervalStart.equals(notYetOverlapedIntervalStart) && !overlapIntervalEnd.equals(notYetOverlapedIntervalEnd)) { intervals .add(new Interval(notYetOverlapedInterval.getStart(), overlapInterval.getStart().minusDays(1))); intervals.add(new Interval(overlapInterval.getEnd().plusDays(1), notYetOverlapedInterval.getEnd())); } return intervals; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.resourceAllocationManager.writtenEvaluations.SearchWrittenEvaluationsByDate.java
License:Open Source License
public ActionForward search(ActionMapping mapping, HttpServletRequest request, final LocalDate day, final LocalTime begin, final LocalTime end, DynaActionForm dynaActionForm) throws Exception { Integer totalOfStudents = 0;//from w ww. j a va 2s . c o m 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"); }
From source file:org.apache.fineract.portfolio.calendar.domain.Calendar.java
License:Apache License
@SuppressWarnings("null") public Map<String, Object> updateRepeatingCalendar(final LocalDate calendarStartDate, final CalendarFrequencyType frequencyType, final Integer interval, final Integer repeatsOnDay) { final Map<String, Object> actualChanges = new LinkedHashMap<>(9); if (calendarStartDate != null & this.startDate != null) { if (!calendarStartDate.equals(this.getStartDateLocalDate())) { actualChanges.put("startDate", calendarStartDate); this.startDate = calendarStartDate.toDate(); }// w w w . j av a 2 s .c om } final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, repeatsOnDay); if (!StringUtils.isBlank(this.recurrence) && !newRecurrence.equalsIgnoreCase(this.recurrence)) { actualChanges.put("recurrence", newRecurrence); this.recurrence = newRecurrence; } return actualChanges; }