List of usage examples for org.joda.time DateMidnight DateMidnight
public DateMidnight(Object instant)
From source file:net.naonedbus.fragment.impl.HorairesFragment.java
License:Open Source License
@Override protected AsyncResult<ListAdapter> loadContent(final Context context, final Bundle bundle) { mIsLoading.set(true);// w w w . j a va 2 s.com final AsyncResult<ListAdapter> result = new AsyncResult<ListAdapter>(); if (DBG) Log.d(LOG_TAG, "\tloadContent " + mDayToLoad.toString()); try { final List<Horaire> data = mHoraireManager.getSchedules(context.getContentResolver(), mArret, mDayToLoad, mLastDateTimeLoaded); if (data.size() == 0) { // Si le prcdent chargement dj charger la totalit du jour // actuel (ligne de nuit par exemple) ne pas rafficher le jour. if (((mLastDayLoaded == null || mLastDateTimeLoaded == null) || !mLastDayLoaded.equals(mLastDateTimeLoaded.toDateMidnight()))) { mHoraires.add(new EmptyHoraire(R.string.msg_nothing_horaires, mLastDayLoaded)); } } else { mHoraires.addAll(data); final Horaire lastHoraire = mHoraires.get(mHoraires.size() - 1); mLastDateTimeLoaded = lastHoraire.getHoraire(); } mLastDayLoaded = new DateMidnight(mDayToLoad); result.setResult(mAdapter); } catch (final Exception e) { result.setException(e); } return result; }
From source file:net.naonedbus.manager.impl.HoraireManager.java
License:Open Source License
@Override public Horaire getSingleFromCursor(final Cursor c) { final Horaire item = new Horaire(); item.setId(c.getInt(mColId));//from ww w .j av a2 s . c om try { item.setJour(new DateMidnight(mIso8601Format.parse(c.getString(mColJour)))); item.setHoraire(new DateTime(mIso8601Format.parse(c.getString(mColHoraire)))); } catch (ParseException e) { e.printStackTrace(); } item.setTerminus(c.getString(mColTerminus)); item.setSection(new DateMidnight(item.getHoraire())); return item; }
From source file:net.naonedbus.rest.controller.impl.HoraireController.java
License:Open Source License
/** * Rcuprer les horaires depuis le WebService. * /*from w w w. j a v a2 s . co m*/ * @throws IOException * @throws MalformedURLException */ public synchronized List<Horaire> getAllFromWeb(final Arret arret, final DateMidnight date) throws IOException { final UrlBuilder url = new UrlBuilder(PATH); final List<HoraireNode> horaires; List<Horaire> result = null; url.addSegment(arret.getCodeArret()); url.addSegment(arret.getCodeLigne()); url.addSegment(arret.getCodeSens()); url.addSegment(mDateFormat.format(date.toDate())); final HoraireContainer content = parseJsonObject(url.getUrl()); MutableDateTime mutableDateTime = new MutableDateTime(date); if (content != null) { horaires = content.horaires; result = new ArrayList<Horaire>(); int lastHour = Integer.MIN_VALUE; // Transformation des horaires TAN en horaire naonedbus. for (final HoraireNode horaireTan : horaires) { final int hour = Integer.parseInt(horaireTan.heure.replaceAll("[^\\d.]", "")); mutableDateTime.setHourOfDay(hour); // Changement de jour if (hour < lastHour) { mutableDateTime.addDays(1); } lastHour = hour; for (final String passage : horaireTan.passages) { int minute = Integer.parseInt(passage.replaceAll("[^\\d.]", "")); mutableDateTime.setMinuteOfHour(minute); final Horaire horaire = new Horaire(); horaire.setJour(date); horaire.setHoraire(mutableDateTime.toDateTime()); horaire.setTerminus(parseTerminus(passage, content.notes)); horaire.setSection(new DateMidnight(horaire.getHoraire())); result.add(horaire); } } } return result; }
From source file:net.sourceforge.fenixedu.domain.Attends.java
License:Open Source License
public Interval getCurrentWeek() { final DateMidnight beginningOfSemester = new DateMidnight(getBegginingOfLessonPeriod()); final DateMidnight firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1); final int currentWeek = calculateCurrentWeekOffset(); final DateMidnight start = firstMonday.plusWeeks(currentWeek); return new Interval(start, start.plusWeeks(1)); }
From source file:net.sourceforge.fenixedu.domain.Attends.java
License:Open Source License
public Interval getResponseWeek() { final DateMidnight beginningOfSemester = new DateMidnight(getBegginingOfLessonPeriod()); final DateMidnight firstMonday = beginningOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1); final DateMidnight secondMonday = firstMonday.plusWeeks(1); final DateMidnight endOfSemester = new DateMidnight(getEndOfExamsPeriod()); final DateMidnight lastMonday = endOfSemester.withField(DateTimeFieldType.dayOfWeek(), 1); final DateMidnight endOfResponsePeriod = lastMonday.plusWeeks(2); return (secondMonday.isEqualNow() || secondMonday.isBeforeNow()) && endOfResponsePeriod.isAfterNow() ? getPreviousWeek()//from w ww . j av a 2 s . com : null; }
From source file:net.sourceforge.fenixedu.domain.Attends.java
License:Open Source License
public int calculateCurrentWeekOffset() { final DateMidnight beginningOfLessonPeriod = new DateMidnight(getBegginingOfLessonPeriod()); final DateMidnight firstMonday = beginningOfLessonPeriod.withField(DateTimeFieldType.dayOfWeek(), 1); final DateMidnight thisMonday = new DateMidnight().withField(DateTimeFieldType.dayOfWeek(), 1); final Interval interval = new Interval(firstMonday, thisMonday); return interval.toPeriod(PeriodType.weeks()).getWeeks(); }
From source file:op.care.bhp.PnlBHP.java
License:Open Source License
private java.util.List<Component> addFilter() { java.util.List<Component> list = new ArrayList<Component>(); jdcDatum = new JDateChooser(new Date()); jdcDatum.setFont(new Font("Arial", Font.PLAIN, 18)); jdcDatum.setMinSelectableDate(BHPTools.getMinDatum(resident)); jdcDatum.setBackground(Color.WHITE); jdcDatum.addPropertyChangeListener(new PropertyChangeListener() { @Override//from ww w.ja v a 2s. c om public void propertyChange(PropertyChangeEvent evt) { if (initPhase) { return; } if (evt.getPropertyName().equals("date")) { reloadDisplay(); } } }); list.add(jdcDatum); JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); buttonPanel.setLayout(new HorizontalLayout(5)); buttonPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); JButton homeButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start.png"))); homeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDatum.setDate(jdcDatum.getMinSelectableDate()); } }); homeButton.setPressedIcon( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start_pressed.png"))); homeButton.setBorder(null); homeButton.setBorderPainted(false); homeButton.setOpaque(false); homeButton.setContentAreaFilled(false); homeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JButton backButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back.png"))); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDatum.getDate()); DateMidnight min = new DateMidnight(jdcDatum.getMinSelectableDate()); if (current.equals(min)) { return; } jdcDatum.setDate(SYSCalendar.addDate(jdcDatum.getDate(), -1)); } }); backButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back_pressed.png"))); backButton.setBorder(null); backButton.setBorderPainted(false); backButton.setOpaque(false); backButton.setContentAreaFilled(false); backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JButton fwdButton = new JButton(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play.png"))); fwdButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDatum.getDate()); if (current.equals(new DateMidnight())) { return; } jdcDatum.setDate(SYSCalendar.addDate(jdcDatum.getDate(), 1)); } }); fwdButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play_pressed.png"))); fwdButton.setBorder(null); fwdButton.setBorderPainted(false); fwdButton.setOpaque(false); fwdButton.setContentAreaFilled(false); fwdButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JButton endButton = new JButton(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end.png"))); endButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDatum.setDate(new Date()); } }); endButton.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end_pressed.png"))); endButton.setBorder(null); endButton.setBorderPainted(false); endButton.setOpaque(false); endButton.setContentAreaFilled(false); endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); buttonPanel.add(homeButton); buttonPanel.add(backButton); buttonPanel.add(fwdButton); buttonPanel.add(endButton); list.add(buttonPanel); // panelFilter.setContentPane(labelPanel); return list; }
From source file:op.care.dfn.PnlDFN.java
License:Open Source License
private List<Component> addFilters() { List<Component> list = new ArrayList<Component>(); jdcDate = new JDateChooser(new Date()); jdcDate.setFont(new Font("Arial", Font.PLAIN, 14)); jdcDate.setBackground(Color.WHITE); list.add(jdcDate);/*from w w w . ja va 2 s .com*/ JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); buttonPanel.setLayout(new HorizontalLayout(5)); buttonPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); final JButton homeButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start.png"))); homeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDate.setDate(jdcDate.getMinSelectableDate()); } }); homeButton.setPressedIcon( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_start_pressed.png"))); homeButton.setBorder(null); homeButton.setBorderPainted(false); homeButton.setOpaque(false); homeButton.setContentAreaFilled(false); homeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton backButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back.png"))); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDate.getDate()); DateMidnight min = new DateMidnight(jdcDate.getMinSelectableDate()); if (current.equals(min)) { return; } jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), -1)); } }); backButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_back_pressed.png"))); backButton.setBorder(null); backButton.setBorderPainted(false); backButton.setOpaque(false); backButton.setContentAreaFilled(false); backButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton fwdButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play.png"))); fwdButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { DateMidnight current = new DateMidnight(jdcDate.getDate()); if (current.equals(new DateMidnight())) { return; } jdcDate.setDate(SYSCalendar.addDate(jdcDate.getDate(), 1)); } }); fwdButton .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_play_pressed.png"))); fwdButton.setBorder(null); fwdButton.setBorderPainted(false); fwdButton.setOpaque(false); fwdButton.setContentAreaFilled(false); fwdButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final JButton endButton = new JButton( new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end.png"))); endButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { jdcDate.setDate(new Date()); } }); endButton.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/bw/player_end_pressed.png"))); endButton.setBorder(null); endButton.setBorderPainted(false); endButton.setOpaque(false); endButton.setContentAreaFilled(false); endButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); buttonPanel.add(homeButton); buttonPanel.add(backButton); buttonPanel.add(fwdButton); buttonPanel.add(endButton); list.add(buttonPanel); jdcDate.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (initPhase) { return; } if (evt.getPropertyName().equals("date")) { reloadDisplay(); } } }); return list; }
From source file:op.care.dfn.PnlDFN.java
License:Open Source License
private java.util.List<Component> addCommands() { java.util.List<Component> list = new ArrayList<Component>(); /***//from w w w . j a va 2 s . c o m * _ _ _ _ _ * | |__ | |_ _ __ / \ __| | __| | * | '_ \| __| '_ \ / _ \ / _` |/ _` | * | |_) | |_| | | |/ ___ \ (_| | (_| | * |_.__/ \__|_| |_/_/ \_\__,_|\__,_| * */ if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { final JideButton btnAdd = GUITools.createHyperlinkButton(SYSTools.xx("nursingrecords.dfn.btnadd"), SYSConst.icon22add, null); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!resident.isActive()) { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident")); return; } final JidePopup popup = new JidePopup(); popup.setMovable(false); PnlSelectIntervention pnl = new PnlSelectIntervention(new Closure() { @Override public void execute(Object o) { popup.hidePopup(); if (o != null) { Object[] objects = (Object[]) o; EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); for (Object obj : objects) { Intervention intervention = em.merge((Intervention) obj); DFN dfn = em.merge(new DFN(resident, intervention)); // Set Target and Actual according to the setting of JDCDate DateTime now = new DateTime(); DateMidnight onDemandPIT = new DateMidnight(jdcDate.getDate()); DateTime newDateTime = onDemandPIT.toDateTime() .plusHours(now.getHourOfDay()).plusMinutes(now.getMinuteOfHour()) .plusSeconds(now.getSecondOfMinute()); dfn.setSoll(newDateTime.toDate()); dfn.setIst(newDateTime.toDate()); CollapsiblePane cp1 = createCP4(dfn); synchronized (mapDFN2Pane) { mapDFN2Pane.put(dfn, cp1); } synchronized (mapShift2DFN) { mapShift2DFN.get(dfn.getShift()).add(dfn); } } em.getTransaction().commit(); CollapsiblePane cp2 = createCP4(DFNTools.SHIFT_ON_DEMAND); synchronized (mapShift2Pane) { mapShift2Pane.put(DFNTools.SHIFT_ON_DEMAND, cp2); } buildPanel(false); try { synchronized (mapShift2Pane) { mapShift2Pane.get(DFNTools.SHIFT_ON_DEMAND).setCollapsed(false); } } catch (PropertyVetoException e) { OPDE.debug(e); } } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.getContentPane().add(pnl); popup.setOwner(btnAdd); popup.removeExcludedComponent(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.NORTH); } }); list.add(btnAdd); } final JideButton printPrescription = GUITools.createHyperlinkButton("nursingrecords.dfn.print", SYSConst.icon22print2, new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { String html = ""; synchronized (mapShift2DFN) { html += "<h1 id=\"fonth1\" >" + ResidentTools.getFullName(resident) + "</h1>"; html += SYSConst.html_h2(SYSTools.xx("nursingrecords.bhp") + ": " + SYSConst.html_bold(DateFormat.getDateInstance().format(jdcDate.getDate()))); for (Byte shift : new Byte[] { DFNTools.SHIFT_ON_DEMAND, DFNTools.SHIFT_VERY_EARLY, DFNTools.SHIFT_EARLY, DFNTools.SHIFT_LATE, DFNTools.SHIFT_VERY_LATE }) { html += DFNTools.getDFNsAsHTMLtable(mapShift2DFN.get(shift)); } } SYSFilesTools.print(html, true); } }); list.add(printPrescription); return list; }
From source file:op.care.nursingprocess.PnlSchedule.java
License:Open Source License
public void save() throws NumberFormatException { boolean splitSetToTime = splitRegularPos == 0d; if (!isAtLeastOneTxtFieldNotZero() && Double.parseDouble(txtUhrzeit.getText()) == 0d) { throw new NumberFormatException("Anzahl der Durchfhrungen steht auf null."); }/*from w w w .j a v a 2 s . c o m*/ is.setNachtMo(splitSetToTime ? (short) 0 : Short.parseShort(txtNachtMo.getText())); is.setMorgens(splitSetToTime ? (short) 0 : Short.parseShort(txtMorgens.getText())); is.setMittags(splitSetToTime ? (short) 0 : Short.parseShort(txtMittags.getText())); is.setNachmittags(splitSetToTime ? (short) 0 : Short.parseShort(txtNachmittags.getText())); is.setAbends(splitSetToTime ? (short) 0 : Short.parseShort(txtAbends.getText())); is.setNachtAb(splitSetToTime ? (short) 0 : Short.parseShort(txtNachtAb.getText())); is.setUhrzeitAnzahl(!splitSetToTime ? (short) 0 : Short.parseShort(txtUhrzeit.getText())); is.setUhrzeit(!splitSetToTime ? null : (Date) cmbUhrzeit.getSelectedItem()); is.setTaeglich(tabWdh.getSelectedIndex() == TAB_DAILY ? Short.parseShort(spinTaeglich.getValue().toString()) : (short) 0); is.setWoechentlich( tabWdh.getSelectedIndex() == TAB_WEEKLY ? Short.parseShort(spinWoche.getValue().toString()) : (short) 0); is.setMonatlich(tabWdh.getSelectedIndex() == TAB_MONTHLY ? Short.parseShort(spinMonat.getValue().toString()) : (short) 0); DateMidnight day; try { day = new DateMidnight(SYSCalendar.parseDate(txtLDate.getText())); } catch (NumberFormatException ex) { day = new DateMidnight(); } is.setLDatum(day.toDate()); is.setMon(tabWdh.getSelectedIndex() == TAB_WEEKLY && cbMon.isSelected() ? (short) 1 : (short) 0); is.setDie(tabWdh.getSelectedIndex() == TAB_WEEKLY && cbDie.isSelected() ? (short) 1 : (short) 0); is.setMit(tabWdh.getSelectedIndex() == TAB_WEEKLY && cbMit.isSelected() ? (short) 1 : (short) 0); is.setDon(tabWdh.getSelectedIndex() == TAB_WEEKLY && cbDon.isSelected() ? (short) 1 : (short) 0); is.setFre(tabWdh.getSelectedIndex() == TAB_WEEKLY && cbFre.isSelected() ? (short) 1 : (short) 0); is.setSam(tabWdh.getSelectedIndex() == TAB_WEEKLY && cbSam.isSelected() ? (short) 1 : (short) 0); is.setSon(tabWdh.getSelectedIndex() == TAB_WEEKLY && cbSon.isSelected() ? (short) 1 : (short) 0); if (tabWdh.getSelectedIndex() == TAB_MONTHLY) { short s = Short.parseShort(spinMonatTag.getValue().toString()); is.setTagNum(cmbTag.getSelectedIndex() == 0 ? s : (short) 0); if (cmbTag.getSelectedIndex() == 1) { is.setMon(s); } else if (cmbTag.getSelectedIndex() == 2) { is.setDie(s); } else if (cmbTag.getSelectedIndex() == 3) { is.setMit(s); } else if (cmbTag.getSelectedIndex() == 4) { is.setDon(s); } else if (cmbTag.getSelectedIndex() == 5) { is.setFre(s); } else if (cmbTag.getSelectedIndex() == 6) { is.setSam(s); } else if (cmbTag.getSelectedIndex() == 7) { is.setSon(s); } } is.setFloating(tbFloating.isSelected()); is.setBemerkung(txtBemerkung.getText()); is.setDauer(SYSTools.parseDecimal(txtMinutes.getText())); if (!is.isValid()) { throw new NumberFormatException("Anzahl muss min. 1 sein"); } }