List of usage examples for org.joda.time MutableDateTime MutableDateTime
public MutableDateTime(Object instant)
From source file:com.soen.hasslefree.beans.PhysicianAvailabilityBean.java
public String addAvailability() { String[] startSplit = startTimeHolder.split(":"); String[] endSplit = endTimeHolder.split(":"); MutableDateTime startDateTime = new MutableDateTime(dateHolder); MutableDateTime endDateTime = new MutableDateTime(dateHolder); String patientEmail = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap() .get("patientEmail"); // Setting start time value from string input startDateTime.setHourOfDay(Integer.parseInt(startSplit[0])); startDateTime.setMinuteOfHour(Integer.parseInt(startSplit[1])); // Setting end time value from string input endDateTime.setHourOfDay(Integer.parseInt(endSplit[0])); endDateTime.setMinuteOfHour(Integer.parseInt(endSplit[1])); PhysicianAvailability pa = new PhysicianAvailability(); pa.setStartTime(startDateTime.toDateTime()); pa.setEndTime(endDateTime.toDateTime()); pa.setRelatedPhysician(Physician.getPhysicianByEmail(patientEmail)); pa.savePhysicianAvailability();/*w w w . j a va 2 s.c om*/ return "myAvailabilities"; }
From source file:com.soen.hasslefree.beans.RegistrationBean.java
public String registerPatient() { Address patientAddress = new Address(); MutableDateTime dateOfBirthMod = new MutableDateTime(dateOfBirth); patientAddress.setApartmentNumber(aptNumber); patientAddress.setCity(city);/*from www.j a v a2 s . co m*/ patientAddress.setCountry(country); patientAddress.setPostalCode(postalCode); patientAddress.setProvince(province); patientAddress.setStreetName(streetName); patientAddress.setStreetNumber(streetNumber); patientAddress.saveAddress(); Patient patient = new Patient(); patient.setFirstName(firstName); patient.setLastName(lastName); patient.setGender(gender); patient.setPassword(encryptPassword(password)); patient.setPhoneNumber(phoneNumber); patient.setDateOfBirth(dateOfBirthMod.toDateTime()); patient.setEmail(emailAddress); patient.setHealthCardNumber(healthCardNumber); patient.setHomeAddress(patientAddress); patient.savePatient(); User.setUserRole(emailAddress, "patient"); return "index"; }
From source file:com.tmathmeyer.sentinel.models.data.Commitment.java
License:Open Source License
@Override public void setTime(DateTime newTime) { MutableDateTime mdt = new MutableDateTime(this.duedate); mdt.setDayOfYear(newTime.getDayOfYear()); mdt.setYear(newTime.getYear());//www .j ava2s . co m this.duedate = mdt.toDate(); }
From source file:com.tmathmeyer.sentinel.models.data.Commitment.java
License:Open Source License
/** * this is primarily used for multiday events * /*from w ww. jav a2s . co m*/ * @param givenDay gets the time that this event starts on a given day * @return when this event starts */ public DateTime getStartTimeOnDay(DateTime givenDay) { MutableDateTime mDisplayedDay = new MutableDateTime(givenDay); mDisplayedDay.setMillisOfDay(1); // if it starts before the beginning of the day then its a multi day // event, or all day event if (this.getStart().isBefore(mDisplayedDay)) { mDisplayedDay.setMillisOfDay(0); return (mDisplayedDay.toDateTime()); } else return this.getStart(); }
From source file:com.tmathmeyer.sentinel.models.data.Commitment.java
License:Open Source License
/** * this is primarily used for multiday events * //from w w w .j a v a 2 s . c o m * @param givenDay gets the time that this event ends on a given day * @return when this event ends */ public DateTime getEndTimeOnDay(DateTime givenDay) { MutableDateTime mDisplayedDay = new MutableDateTime(givenDay); ; mDisplayedDay.setMillisOfDay(86400000 - 2); if (this.getStart().plusMinutes(30).isAfter(mDisplayedDay)) { return mDisplayedDay.toDateTime(); } else return this.getStart().plusMinutes(30); }
From source file:com.tmathmeyer.sentinel.models.data.Event.java
License:Open Source License
/** * this is primarily used for multiday events * //from w ww. ja va2s .co m * @param givenDay gets the time that this event ends on a given day * @return when this event ends */ public DateTime getEndTimeOnDay(DateTime givenDay) { MutableDateTime mDisplayedDay = new MutableDateTime(givenDay); ; mDisplayedDay.setMillisOfDay(86400000 - 2); if (this.getEnd().isAfter(mDisplayedDay)) { return mDisplayedDay.toDateTime(); } else return this.getEnd(); }
From source file:com.tmathmeyer.sentinel.models.data.Event.java
License:Open Source License
@Override public void setTime(DateTime newTime) { if (new Interval(new DateTime(this.start), new DateTime(this.end)).contains(newTime)) { // this is what stops the events from being dragged to the next day. // leaving it in case we might want it later // return; }/* w w w .java 2s.co m*/ Interval i; int daysBetween = 0; if (new DateTime(this.start).isAfter(newTime)) { i = new Interval(newTime, new DateTime(this.start)); daysBetween = 0 - (int) i.toDuration().getStandardDays(); } else { i = new Interval(new DateTime(this.start), newTime); daysBetween = (int) i.toDuration().getStandardDays(); } MutableDateTime newEnd = new MutableDateTime(this.end); newEnd.addDays(daysBetween); MutableDateTime newStart = new MutableDateTime(this.start); newStart.addDays(daysBetween); this.end = newEnd.toDate(); this.start = newStart.toDate(); }
From source file:com.tmathmeyer.sentinel.ui.navigation.CalendarNavigationModule.java
License:Open Source License
public CalendarNavigationModule getPrevious() { MutableDateTime next = new MutableDateTime(time); next.addMonths(-1);/*from w w w .java2 s . c o m*/ return new CalendarNavigationModule(next.toDateTime(), mc, monthOnly); }
From source file:com.tmathmeyer.sentinel.ui.navigation.CalendarNavigationModule.java
License:Open Source License
public CalendarNavigationModule getFollowing() { MutableDateTime next = new MutableDateTime(time); next.addMonths(1);// w w w. j ava2 s. co m return new CalendarNavigationModule(next.toDateTime(), mc, monthOnly); }
From source file:com.tmathmeyer.sentinel.ui.navigation.MiniMonth.java
License:Open Source License
public MiniMonth(DateTime time, final MiniCalendarHostIface mc, boolean monthOnly) { this.setLayout(new GridLayout(7, 7)); MutableDateTime prevMonth = new MutableDateTime(time); prevMonth.setDayOfMonth(1);//from www . j a va 2s . c om prevMonth.addMonths(-1); // What is prevMonth for? String[] dayLabel = { "S", "M", "T", "W", "R", "F", "S" }; MouseListener monthChanger = new MouseListener() { @Override public void mouseClicked(MouseEvent me) { } @Override public void mouseEntered(MouseEvent me) { } @Override public void mouseExited(MouseEvent me) { } @Override public void mousePressed(MouseEvent me) { } @Override public void mouseReleased(MouseEvent me) { DayLabel d = (DayLabel) (me.getSource()); if (!(d instanceof DescriptiveDayLabel)) { mc.display(d.getMonth()); } } }; MutableDateTime referenceDay = new MutableDateTime(time); // reset to the first of the month at midnight, then find Sunday referenceDay.setDayOfMonth(1); referenceDay.setMillisOfDay(0); int first = referenceDay.getDayOfWeek(); referenceDay.addDays(-first); boolean flipFlop = false; // add day labels for (int i = 0; i < 7; i++) { DayLabel day = new DescriptiveDayLabel(dayLabel[i], time); day.borderize((i % 7) == 0, i >= 5 * 7, (i % 7) == 6); add(day); day.addMouseListener(monthChanger); } // generate days, 6*7 covers all possible months, so we just loop // through and add each day for (int i = 0; i < (6 * 7); i++) { DayLabel day; if (monthOnly || MainPanel.getInstance().getView() == ViewSize.Month) { if (referenceDay.getDayOfMonth() == 1) flipFlop ^= true; // flops the flip flop flappity flip } else if (MainPanel.getInstance().getView() == ViewSize.Day) flipFlop = referenceDay.getDayOfYear() == time.getDayOfYear() && referenceDay.getYear() == time.getYear(); else if (MainPanel.getInstance().getView() == ViewSize.Week) { if (Months.getWeekStart(time).getMonthOfYear() == 12 && Months.getWeekStart(time).getDayOfMonth() >= 26) // Exception // case // for // weeks // between // years flipFlop = time.getMonthOfYear() == 12 ? i >= 35 : i <= 6; else flipFlop = referenceDay.getDayOfYear() >= Months.getWeekStart(time).getDayOfYear() && referenceDay.getDayOfYear() <= Months.getWeekStart(time).getDayOfYear() + 6; } if (flipFlop) day = new ActiveDayLabel(referenceDay.toDateTime()); else day = new InactiveDayLabel(referenceDay.toDateTime()); day.borderize((i % 7) == 0, i >= 5 * 7, (i % 7) == 6); add(day); day.addMouseListener(monthChanger); referenceDay.addDays(1); // go to next day } }