List of usage examples for java.text DateFormat getDateInstance
public static final DateFormat getDateInstance()
From source file:com.zimbra.perf.chart.ChartUtil.java
private void writeIndexHtml(List<ChartSettings> allSettings, Set<String> linkedDocuments) throws IOException { // Generate HTML System.out.println("Writing index.html"); FileWriter writer = null;//from w w w . j a va 2 s . c o m try { writer = new FileWriter(new File(mDestDir, "index.html")); writer.write("<html>\n<head>\n<title>" + StringUtil.escapeHtml(mTitle) + " " + DateFormat.getDateInstance().format(mMinDate) + "</title>\n</head>\n<body bgcolor=\"#eeeeee\">\n"); writer.write("<h1>" + StringUtil.escapeHtml(mTitle) + "</h1>\n"); if (linkedDocuments.size() > 0) { writer.write("<h2>Additional charts</h2>"); writer.write("<ul>"); for (String document : linkedDocuments) { writer.write("<li><a href=\"" + document + "\">"); writer.write(document); writer.write("</a></li>\n"); } writer.write("</ul>\n"); } List<String> noData = new ArrayList<String>(); int count = 0; for (ChartSettings cs : allSettings) { JFreeChart chart = mChartMap.get(cs); if (chart == null) continue; List<PlotSettings> plots = cs.getPlots(); String statString = ""; boolean first = true; for (PlotSettings ps : plots) { DataColumn dc = new DataColumn(ps.getInfile(), ps.getDataColumn()); DataSeries ds = mDataSeries.get(dc); if (ds == null || ds.size() == 0) continue; if (first) first = false; else statString += " "; statString += ps.getAggregateFunction() + "(" + ps.getLegend() + ") = " + formatDouble(mAggregates.get(dc).doubleValue()); count++; } if (hasData(chart)) { writer.write("<a name=\"" + cs.getOutfile() + "\">"); writer.write("<h3>" + cs.getTitle() + "</h3></a>\n"); writer.write("<h5>" + statString + "</h5>\n"); writer.write(String.format("<img src=\"%s\" width=\"%d\" height=\"%d\">\n", cs.getOutfile(), cs.getWidth(), cs.getHeight())); } else { noData.add(cs.getTitle()); } } if (noData.size() > 0) { writer.write("<h3>No data available for the following charts:</h3>\n"); writer.write("<p>\n"); for (String str : noData) { writer.write(StringUtil.escapeHtml(str)); writer.write("\n"); } writer.write("<p>\n"); } if (!mSkipSummary) writer.write("<h4><a href=\"" + SummaryConstants.SUMMARY_TXT + "\">Summary</a></h4>\n"); writer.write("</body>\n</html>\n"); } finally { if (writer != null) writer.close(); } }
From source file:be.shad.tsqb.test.SelectTests.java
/** * Select encoded string property into a date field. */// w w w . j a va 2s. c om @Test public void selectDateTransformedValue() { Product product = query.from(Product.class); ProductDetailsDto dto = query.select(ProductDetailsDto.class); dto.setId(product.getId()); dto.setValidUntilDate(query.select(Date.class, product.getManyProperties().getProperty1(), new SelectionValueTransformer<String, Date>() { @Override public Date convert(String a) { try { return DateFormat.getDateInstance().parse(a); } catch (ParseException e) { throw new RuntimeException(e); } } })); validate("select hobj1.id as id, hobj1.manyProperties.property1 as validUntilDate from Product hobj1"); }
From source file:org.apache.flex.compiler.config.Configuration.java
/** * Write the data to rdf/xml/* www. j av a 2 s . com*/ * * @param writer * @throws XMLStreamException */ private void writeDate(XMLStreamWriter writer) throws XMLStreamException { if (date == null) { date = DateFormat.getDateInstance().format(new Date()); } writer.writeStartElement(DC_URI, "date"); writer.writeCharacters(date); writer.writeEndElement(); }
From source file:op.care.dfn.PnlDFN.java
private CollapsiblePane createCP4(final DFN dfn) { final CollapsiblePane dfnPane = new CollapsiblePane(); ActionListener applyActionListener = new ActionListener() { @Override//from w w w .ja v a 2s . com public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_DONE) { return; } if (!dfn.isOnDemand() && dfn.getNursingProcess().isClosed()) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setState(DFNTools.STATE_DONE); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setIst(new Date()); myDFN.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }; String title = "<html><font size=+1>" + // (dfn.isFloating() ? (dfn.isActive() ? "(!) " : "(OK) ") : "") + SYSTools.left(dfn.getIntervention().getBezeichnung(), MAX_TEXT_LENGTH) + DFNTools.getScheduleText(dfn, " [", "]") + ", " + dfn.getMinutes() + " " + SYSTools.xx("misc.msg.Minute(s)") + (dfn.getUser() != null ? ", <i>" + SYSTools.anonymizeUser(dfn.getUser().getUID()) + "</i>" : "") + "</font></html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) ? applyActionListener : null); dfnPane.setCollapseOnTitleClick(false); // cptitle.getTitleButton().setIcon(DFNTools.getIcon(dfn)); JLabel icon1 = new JLabel(DFNTools.getIcon(dfn)); icon1.setOpaque(false); JLabel icon2 = new JLabel(DFNTools.getFloatingIcon(dfn)); icon2.setOpaque(false); cptitle.getAdditionalIconPanel().add(icon1); cptitle.getAdditionalIconPanel().add(icon2); if (dfn.isFloating()) { cptitle.getButton().setToolTipText(SYSTools.xx("nursingrecords.dfn.enforced.tooltip") + ": " + DateFormat.getDateInstance().format(dfn.getStDatum())); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID) && (dfn.isOnDemand() || !dfn.getNursingProcess().isClosed())) { /*** * _ _ _ _ * | |__ | |_ _ __ / \ _ __ _ __ | |_ _ * | '_ \| __| '_ \ / _ \ | '_ \| '_ \| | | | | * | |_) | |_| | | |/ ___ \| |_) | |_) | | |_| | * |_.__/ \__|_| |_/_/ \_\ .__/| .__/|_|\__, | * |_| |_| |___/ */ JButton btnApply = new JButton(SYSConst.icon22apply); btnApply.setPressedIcon(SYSConst.icon22applyPressed); btnApply.setAlignmentX(Component.RIGHT_ALIGNMENT); btnApply.setContentAreaFilled(false); btnApply.setBorder(null); btnApply.addActionListener(applyActionListener); btnApply.setEnabled(!dfn.isOnDemand() && dfn.isOpen()); cptitle.getRight().add(btnApply); // JPanel spacer = new JPanel(); // spacer.setOpaque(false); // cptitle.getRight().add(spacer); /*** * _ _ ____ _ * | |__ | |_ _ __ / ___|__ _ _ __ ___ ___| | * | '_ \| __| '_ \| | / _` | '_ \ / __/ _ \ | * | |_) | |_| | | | |__| (_| | | | | (_| __/ | * |_.__/ \__|_| |_|\____\__,_|_| |_|\___\___|_| * */ final JButton btnCancel = new JButton(SYSConst.icon22cancel); btnCancel.setPressedIcon(SYSConst.icon22cancelPressed); btnCancel.setAlignmentX(Component.RIGHT_ALIGNMENT); btnCancel.setContentAreaFilled(false); btnCancel.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_REFUSED) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setState(DFNTools.STATE_REFUSED); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setIst(new Date()); myDFN.setiZeit(SYSCalendar.whatTimeIDIs(new Date())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }); btnCancel.setEnabled(!dfn.isOnDemand() && dfn.isOpen()); cptitle.getRight().add(btnCancel); /*** * _ _ _____ _ * | |__ | |_ _ __ | ____|_ __ ___ _ __ | |_ _ _ * | '_ \| __| '_ \| _| | '_ ` _ \| '_ \| __| | | | * | |_) | |_| | | | |___| | | | | | |_) | |_| |_| | * |_.__/ \__|_| |_|_____|_| |_| |_| .__/ \__|\__, | * |_| |___/ */ final JButton btnEmpty = new JButton(SYSConst.icon22empty); btnEmpty.setPressedIcon(SYSConst.icon22emptyPressed); btnEmpty.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEmpty.setContentAreaFilled(false); btnEmpty.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnEmpty.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (dfn.getState() == DFNTools.STATE_OPEN) { return; } if (DFNTools.isChangeable(dfn)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } // on demand DFNs are deleted if they not wanted anymore if (myDFN.isOnDemand()) { em.remove(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.remove(myDFN); } synchronized (mapShift2DFN) { mapShift2DFN.get(myDFN.getShift()).remove(myDFN); } } else { // the normal DFNs (those assigned to a NursingProcess) are reset to the OPEN state. myDFN.setState(DFNTools.STATE_OPEN); myDFN.setUser(null); myDFN.setIst(null); myDFN.setiZeit(null); myDFN.setMdate(new Date()); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } } em.getTransaction().commit(); CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } else { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); } } }); btnEmpty.setEnabled(!dfn.isOpen()); cptitle.getRight().add(btnEmpty); /*** * _ _ __ __ _ _ * | |__ | |_ _ __ | \/ (_)_ __ _ _| |_ ___ ___ * | '_ \| __| '_ \| |\/| | | '_ \| | | | __/ _ \/ __| * | |_) | |_| | | | | | | | | | | |_| | || __/\__ \ * |_.__/ \__|_| |_|_| |_|_|_| |_|\__,_|\__\___||___/ * */ final JButton btnMinutes = new JButton(SYSConst.icon22clock); btnMinutes.setPressedIcon(SYSConst.icon22clockPressed); btnMinutes.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMinutes.setContentAreaFilled(false); btnMinutes.setBorder(null); // btnCancel.setToolTipText(SYSTools.xx("nursingrecords.dfn.btneval.tooltip")); btnMinutes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!DFNTools.isChangeable(dfn)) { OPDE.getDisplayManager() .addSubMessage(new DisplayMessage(SYSTools.xx("nursingrecords.dfn.notchangeable"))); return; } final JPopupMenu menu = SYSCalendar.getMinutesMenu( new int[] { 1, 2, 3, 4, 5, 10, 15, 20, 30, 45, 60, 120, 240, 360 }, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); DFN myDFN = em.merge(dfn); em.lock(myDFN, LockModeType.OPTIMISTIC); if (!myDFN.isOnDemand()) { em.lock(myDFN.getNursingProcess(), LockModeType.OPTIMISTIC); } myDFN.setMinutes(new BigDecimal((Integer) o)); myDFN.setUser(em.merge(OPDE.getLogin().getUser())); myDFN.setMdate(new Date()); em.getTransaction().commit(); CollapsiblePane cp1 = createCP4(myDFN); synchronized (mapDFN2Pane) { mapDFN2Pane.put(myDFN, cp1); } synchronized (mapShift2DFN) { int position = mapShift2DFN.get(myDFN.getShift()).indexOf(myDFN); mapShift2DFN.get(myDFN.getShift()).remove(position); mapShift2DFN.get(myDFN.getShift()).add(position, myDFN); } CollapsiblePane cp2 = createCP4(myDFN.getShift()); synchronized (mapShift2Pane) { mapShift2Pane.put(myDFN.getShift(), cp2); } buildPanel(false); } 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(); } } }); menu.show(btnMinutes, 0, btnMinutes.getHeight()); } }); btnMinutes.setEnabled(dfn.getState() != DFNTools.STATE_OPEN); cptitle.getRight().add(btnMinutes); } /*** * _ _ ___ __ * | |__ | |_ _ __ |_ _|_ __ / _| ___ * | '_ \| __| '_ \ | || '_ \| |_ / _ \ * | |_) | |_| | | || || | | | _| (_) | * |_.__/ \__|_| |_|___|_| |_|_| \___/ * */ final JButton btnInfo = new JButton(SYSConst.icon22info); final JidePopup popupInfo = new JidePopup(); btnInfo.setPressedIcon(SYSConst.icon22infoPressed); btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT); btnInfo.setContentAreaFilled(false); btnInfo.setBorder(null); final JTextPane txt = new JTextPane(); txt.setContentType("text/html"); txt.setEditable(false); popupInfo.setMovable(false); popupInfo.getContentPane().setLayout(new BoxLayout(popupInfo.getContentPane(), BoxLayout.LINE_AXIS)); popupInfo.getContentPane().add(new JScrollPane(txt)); popupInfo.removeExcludedComponent(txt); popupInfo.setDefaultFocusComponent(txt); btnInfo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { popupInfo.setOwner(btnInfo); txt.setText(SYSTools.toHTML(SYSConst.html_div(dfn.getInterventionSchedule().getBemerkung()))); GUITools.showPopup(popupInfo, SwingConstants.WEST); } }); btnInfo.setEnabled( !dfn.isOnDemand() && !SYSTools.catchNull(dfn.getInterventionSchedule().getBemerkung()).isEmpty()); cptitle.getRight().add(btnInfo); dfnPane.setTitleLabelComponent(cptitle.getMain()); dfnPane.setBackground(dfn.getBG()); dfnPane.setForeground(dfn.getFG()); try { dfnPane.setCollapsed(true); } catch (PropertyVetoException e) { OPDE.error(e); } dfnPane.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { JTextPane contentPane = new JTextPane(); contentPane.setContentType("text/html"); contentPane.setEditable(false); contentPane.setText(SYSTools .toHTML(NursingProcessTools.getAsHTML(dfn.getNursingProcess(), false, true, false, false))); dfnPane.setContentPane(contentPane); } }); dfnPane.setCollapsible(dfn.getNursingProcess() != null); dfnPane.setHorizontalAlignment(SwingConstants.LEADING); dfnPane.setOpaque(false); return dfnPane; }
From source file:com.example.mego.adas.main.CarFragment.java
/** * methods used to refresh Ui state and organize the data *///from w w w . ja v a 2 s .c o m public void refreshUI() { //make sure there data before ~ if (endOfLineIndex > 0) { //if it start with # we know that we looking for if (recDataString.charAt(0) == '#') { //get the value from the string between indices String readValueAfterSub = recDataString.substring(1, recDataString.length() - 1); int oldCounter = 0; //create an array that will hold the sensors value ArrayList<String> sensorsValueList = new ArrayList<>(); for (int newCounter = 0; newCounter < readValueAfterSub.length(); newCounter++) { if (readValueAfterSub.charAt(newCounter) == '+') { sensorsValueList.add(readValueAfterSub.substring(oldCounter, newCounter)); oldCounter = newCounter + 1; } } for (int counter = 0; counter < sensorsValueList.size(); counter++) { //get the sensors values sensorsValues.setTemperatureSensorValue(Integer.parseInt(sensorsValueList.get(0))); tempSensorValue = sensorsValues.getTemperatureSensorValue(); tempPublishProcessor.onNext(tempSensorValue); //Temperature in Fahrenheit tempSensorInFahrenheit = (int) AdasUtils.celsiusToFahrenheit(tempSensorValue); sensorsValues.setLdrSensorValue(Integer.parseInt(sensorsValueList.get(1))); ldrSensorValue = sensorsValues.getLdrSensorValue(); ldrPublishProcessor.onNext(ldrSensorValue); sensorsValues.setPotSensorValue(Integer.parseInt(sensorsValueList.get(2))); potSensorValue = sensorsValues.getPotSensorValue(); potPublishProcessor.onNext(potSensorValue); accidentState = (Integer.parseInt(sensorsValueList.get(3))); if (NetworkUtil.isAvailableInternetConnection(getContext())) { accidentStateDatabaseReference.setValue(accidentState); } if (accidentState == 1) { accidentNotificationFlag++; if (accidentNotificationFlag == 1 && !NetworkUtil.isAvailableInternetConnection(getContext())) { NotificationUtils.showAccidentNotification(getContext()); } if (accidentNotificationFlag == 1) { //send a new accident with the current data,time ,longitude and latitude String currentDate = DateFormat.getDateInstance().format(new Date()); String currentTime = DateFormat.getTimeInstance().format(new Date()); Accident accident = new Accident(currentDate, currentTime, "Accident", longitude, latitude, null); if (NetworkUtil.isAvailableInternetConnection(getContext())) { accidentsDatabaseReference.push().setValue(accident); } } } else if (accidentState == 0) { accidentNotificationFlag = 0; } lDRSensorValueTextView.setText( String.format(getString(R.string.current_progress_bar_update), ldrSensorValue + "")); if (isFahrenheit) { tempSensorValueTextView.setText(String.format( getString(R.string.current_progress_bar_update), tempSensorInFahrenheit + "")); } else { tempSensorValueTextView.setText(String .format(getString(R.string.current_progress_bar_update), tempSensorValue + "")); } potSensorValueTextView.setText( String.format(getString(R.string.current_progress_bar_update), potSensorValue + "")); } if (NetworkUtil.isAvailableInternetConnection(getContext())) { //send data to Firebase SensorsValues sensorsValuesSend = new SensorsValues(tempSensorValue, ldrSensorValue, potSensorValue); sensorsValuesDatabaseReference.setValue(sensorsValuesSend); } if (tempSensorValue >= 40) { tempSensorValueTextView.setTextColor(getResources().getColor(R.color.red)); tempTextView.setTextColor(getResources().getColor(R.color.red)); } else { tempSensorValueTextView.setTextColor(getResources().getColor(R.color.colorPrimary)); tempTextView.setTextColor(getResources().getColor(R.color.colorPrimary)); } if (ldrSensorValue >= 800) { lDRSensorValueTextView.setTextColor(getResources().getColor(R.color.red)); ldrTextView.setTextColor(getResources().getColor(R.color.red)); } else { lDRSensorValueTextView.setTextColor(getResources().getColor(R.color.colorPrimary)); ldrTextView.setTextColor(getResources().getColor(R.color.colorPrimary)); } if (potSensorValue >= 800) { potSensorValueTextView.setTextColor(getResources().getColor(R.color.red)); potTextView.setTextColor(getResources().getColor(R.color.red)); } else { potSensorValueTextView.setTextColor(getResources().getColor(R.color.colorPrimary)); potTextView.setTextColor(getResources().getColor(R.color.colorPrimary)); } } //clear all string data recDataString.delete(0, recDataString.length()); } }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.impl.CswRecordConverter.java
private Date convertToDate(String value) { // Dates are strings and expected to be in ISO8601 format, YYYY-MM-DD'T'hh:mm:ss.sss, // per annotations in the CSW Record schema. At least the date portion must be present; // the time zone and time are optional. try {/*from w ww . j a va2 s. c om*/ return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(value).toDate(); } catch (IllegalArgumentException e) { LOGGER.debug("Failed to convert to date {} from ISO Format: {}", value, e); } // failed to convert iso format, attempt to convert from xsd:date or xsd:datetime format // this format is used by the NSG interoperability CITE tests try { return XSD_FACTORY.newXMLGregorianCalendar(value).toGregorianCalendar().getTime(); } catch (IllegalArgumentException e) { LOGGER.debug("Unable to convert date {} from XSD format {} ", value, e); } // try from java date serialization for the default locale try { return DateFormat.getDateInstance().parse(value); } catch (ParseException e) { LOGGER.debug("Unable to convert date {} from default locale format {} ", value, e); } // default to current date LOGGER.warn("Unable to convert {} to a date object, defaulting to current time", value); return new Date(); }
From source file:org.iexhub.services.GetPatientDataService.java
@GET @Path("/ccd") @Produces({ MediaType.APPLICATION_JSON }) public Response getCCD(@Context HttpHeaders headers) { log.info("Entered getPatientData service"); boolean tls = false; tls = (IExHubConfig.getProperty("XdsBRegistryEndpointURI") == null) ? false : ((IExHubConfig.getProperty("XdsBRegistryEndpointURI").toLowerCase().contains("https") ? true : false));/*from w w w. j av a 2 s. com*/ GetPatientDataService.testMode = IExHubConfig.getProperty("TestMode", GetPatientDataService.testMode); GetPatientDataService.testJSONDocumentPathname = IExHubConfig.getProperty("TestJSONDocumentPathname", GetPatientDataService.testJSONDocumentPathname); GetPatientDataService.cdaToJsonTransformXslt = IExHubConfig.getProperty("CDAToJSONTransformXSLT", GetPatientDataService.cdaToJsonTransformXslt); GetPatientDataService.iExHubDomainOid = IExHubConfig.getProperty("IExHubDomainOID", GetPatientDataService.iExHubDomainOid); GetPatientDataService.iExHubAssigningAuthority = IExHubConfig.getProperty("IExHubAssigningAuthority", GetPatientDataService.iExHubAssigningAuthority); GetPatientDataService.xdsBRepositoryUniqueId = IExHubConfig.getProperty("XdsBRepositoryUniqueId", GetPatientDataService.xdsBRepositoryUniqueId); String retVal = ""; GetPatientDataResponse patientDataResponse = new GetPatientDataResponse(); DocumentsResponseDto documentsResponseDto = new DocumentsResponseDto(); List<PatientDocument> patientDocuments = new ArrayList<>(); if (!testMode) { try { if (xdsB == null) { log.info("Instantiating XdsB connector..."); xdsB = new XdsB(null, null, tls); log.info("XdsB connector successfully started"); } } catch (Exception e) { log.error("Error encountered instantiating XdsB connector, " + e.getMessage()); throw new UnexpectedServerException("Error - " + e.getMessage()); } try { MultivaluedMap<String, String> headerParams = headers.getRequestHeaders(); String ssoAuth = headerParams.getFirst("ssoauth"); log.info("HTTP headers successfully retrieved"); String[] splitPatientId = ssoAuth.split("&LastName="); String patientId = (splitPatientId[0].split("=").length == 2) ? splitPatientId[0].split("=")[1] : null; String[] parts = splitPatientId[1].split("&"); String lastName = (parts[0].length() > 0) ? parts[0] : null; String firstName = (parts[1].split("=").length == 2) ? parts[1].split("=")[1] : null; String middleName = (parts[2].split("=").length == 2) ? parts[2].split("=")[1] : null; String dateOfBirth = (parts[3].split("=").length == 2) ? parts[3].split("=")[1] : null; String gender = (parts[4].split("=").length == 2) ? parts[4].split("=")[1] : null; String motherMaidenName = (parts[5].split("=").length == 2) ? parts[5].split("=")[1] : null; String addressStreet = (parts[6].split("=").length == 2) ? parts[6].split("=")[1] : null; String addressCity = (parts[7].split("=").length == 2) ? parts[7].split("=")[1] : null; String addressState = (parts[8].split("=").length == 2) ? parts[8].split("=")[1] : null; String addressPostalCode = (parts[9].split("=").length == 2) ? parts[9].split("=")[1] : null; String otherIDsScopingOrganization = (parts[10].split("=").length == 2) ? parts[10].split("=")[1] : null; String startDate = (parts[11].split("=").length == 2) ? parts[11].split("=")[1] : null; String endDate = (parts[12].split("=").length == 2) ? parts[12].split("=")[1] : null; log.info("HTTP headers successfully parsed, now calling XdsB registry..."); // Determine if a complete patient ID (including OID and ISO specification) was provided. If not, then append IExHubDomainOid and IExAssigningAuthority... if (!patientId.contains("^^^&")) { patientId = "'" + patientId + "^^^&" + GetPatientDataService.iExHubDomainOid + "&" + GetPatientDataService.iExHubAssigningAuthority + "'"; } AdhocQueryResponse registryResponse = xdsB.registryStoredQuery(patientId, (startDate != null) ? DateFormat.getDateInstance().format(startDate) : null, (endDate != null) ? DateFormat.getDateInstance().format(endDate) : null); log.info("Call to XdsB registry successful"); // Determine if registry server returned any errors... if ((registryResponse.getRegistryErrorList() != null) && (registryResponse.getRegistryErrorList().getRegistryError().length > 0)) { for (RegistryError_type0 error : registryResponse.getRegistryErrorList().getRegistryError()) { StringBuilder errorText = new StringBuilder(); if (error.getErrorCode() != null) { errorText.append("Error code=" + error.getErrorCode() + "\n"); } if (error.getCodeContext() != null) { errorText.append("Error code context=" + error.getCodeContext() + "\n"); } // Error code location (i.e., stack trace) only to be logged to IExHub error file patientDataResponse.getErrorMsgs().add(errorText.toString()); if (error.getLocation() != null) { errorText.append("Error location=" + error.getLocation()); } log.error(errorText.toString()); } } // Try to retrieve documents... RegistryObjectListType registryObjectList = registryResponse.getRegistryObjectList(); IdentifiableType[] documentObjects = registryObjectList.getIdentifiable(); if ((documentObjects != null) && (documentObjects.length > 0)) { log.info("Documents found in the registry, retrieving them from the repository..."); HashMap<String, String> documents = new HashMap<String, String>(); for (IdentifiableType identifiable : documentObjects) { if (identifiable.getClass().equals(ExtrinsicObjectType.class)) { // Determine if the "home" attribute (homeCommunityId in XCA parlance) is present... String home = ((((ExtrinsicObjectType) identifiable).getHome() != null) && (((ExtrinsicObjectType) identifiable).getHome().getPath().length() > 0)) ? ((ExtrinsicObjectType) identifiable).getHome().getPath() : null; ExternalIdentifierType[] externalIdentifiers = ((ExtrinsicObjectType) identifiable) .getExternalIdentifier(); // Find the ExternalIdentifier that has the "XDSDocumentEntry.uniqueId" value... String uniqueId = null; for (ExternalIdentifierType externalIdentifier : externalIdentifiers) { String val = externalIdentifier.getName().getInternationalStringTypeSequence()[0] .getLocalizedString().getValue().getFreeFormText(); if ((val != null) && (val.compareToIgnoreCase("XDSDocumentEntry.uniqueId") == 0)) { log.info("Located XDSDocumentEntry.uniqueId ExternalIdentifier, uniqueId=" + uniqueId); uniqueId = externalIdentifier.getValue().getLongName(); break; } } if (uniqueId != null) { documents.put(uniqueId, home); log.info("Document ID added: " + uniqueId + ", homeCommunityId: " + home); } } else { String home = ((identifiable.getHome() != null) && (identifiable.getHome().getPath().length() > 0)) ? identifiable.getHome().getPath() : null; documents.put(identifiable.getId().getPath(), home); log.info("Document ID added: " + identifiable.getId().getPath() + ", homeCommunityId: " + home); } } log.info("Invoking XdsB repository connector retrieval..."); RetrieveDocumentSetResponse documentSetResponse = xdsB .retrieveDocumentSet(xdsBRepositoryUniqueId, documents, patientId); log.info("XdsB repository connector retrieval succeeded"); // Invoke appropriate map(s) to process documents in documentSetResponse... if (documentSetResponse.getRetrieveDocumentSetResponse() .getRetrieveDocumentSetResponseTypeSequence_type0() != null) { DocumentResponse_type0[] docResponseArray = documentSetResponse .getRetrieveDocumentSetResponse().getRetrieveDocumentSetResponseTypeSequence_type0() .getDocumentResponse(); if (docResponseArray != null) { try { for (DocumentResponse_type0 document : docResponseArray) { log.info("Processing document ID=" + document.getDocumentUniqueId().getLongName()); String mimeType = docResponseArray[0].getMimeType().getLongName(); if (mimeType.compareToIgnoreCase("text/xml") == 0) { DataHandler dh = document.getDocument(); String documentStr = dh.getContent().toString(); String documentName = document.getDocumentUniqueId().getLongName(); PatientDocument patientDocument = new PatientDocument(documentName, documentStr); patientDocuments.add(patientDocument); } else { patientDataResponse.getErrorMsgs() .add("Document retrieved is not XML - document ID=" + document.getDocumentUniqueId().getLongName()); } } } catch (Exception e) { log.error("Error encountered, " + e.getMessage()); throw e; } } } } } catch (Exception e) { log.error("Error encountered, " + e.getMessage()); throw new UnexpectedServerException("Error - " + e.getMessage()); } } else { // Return test document when testMode is true try { retVal = FileUtils.readFileToString(new File(GetPatientDataService.testJSONDocumentPathname)); return Response.status(Response.Status.OK).entity(retVal).type(MediaType.APPLICATION_JSON).build(); } catch (Exception e) { throw new UnexpectedServerException("Error - " + e.getMessage()); } } documentsResponseDto.setDocuments(patientDocuments); return Response.status(Response.Status.OK).entity(documentsResponseDto).type(MediaType.APPLICATION_JSON) .build(); }
From source file:op.care.nursingprocess.PnlNursingProcess.java
private String getHyperlinkButtonTextFor(NursingProcess planung) { String result = "<b>" + planung.getTopic() + "</b> "; if (planung.isClosed()) { result += DateFormat.getDateInstance().format(planung.getFrom()) + " → " + DateFormat.getDateInstance().format(planung.getTo()); } else {/*from w w w.j a v a2s. c o m*/ result += DateFormat.getDateInstance().format(planung.getFrom()) + " →| "; } return SYSTools.toHTMLForScreen(result); }
From source file:com.javielinux.utils.Utils.java
public static String timeFromTweet(Context cnt, Date timeTweet) { if (Integer.parseInt(Utils.getPreference(cnt).getString("prf_date_format", "1")) == 1) { return diffDate(new Date(), timeTweet); } else {//from w ww .j a v a 2 s . c om Date now = new Date(); if (now.getDay() == timeTweet.getDay() && now.getMonth() == timeTweet.getMonth() && now.getYear() == timeTweet.getYear()) { return DateFormat.getTimeInstance().format(timeTweet); } else { return DateFormat.getDateInstance().format(timeTweet); } } }
From source file:op.care.reports.PnlReport.java
private CollapsiblePane createCP4Day(final LocalDate day) { final String key = DateFormat.getDateInstance().format(day.toDate()); synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. }/*from w ww . j ava 2s . c om*/ } } final CollapsiblePane cpDay = cpMap.get(key); String titleDay = "<html><font size=+1>" + dayFormat.format(day.toDate()) + SYSTools.catchNull(holidays.get(day), " (", ")") + "</font></html>"; final DefaultCPTitle titleCPDay = new DefaultCPTitle(titleDay, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpDay.setCollapsed(!cpDay.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) { final JButton btnPrintDay = new JButton(SYSConst.icon22print2); btnPrintDay.setPressedIcon(SYSConst.icon22print2Pressed); btnPrintDay.setAlignmentX(Component.RIGHT_ALIGNMENT); btnPrintDay.setContentAreaFilled(false); btnPrintDay.setBorder(null); btnPrintDay.setToolTipText(SYSTools.xx("misc.tooltips.btnprintday")); btnPrintDay.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { SYSFilesTools.print(NReportTools.getNReportsAsHTML(NReportTools.getNReports4Day(resident, day), true, null, null), false); } }); titleCPDay.getRight().add(btnPrintDay); } cpDay.setTitleLabelComponent(titleCPDay.getMain()); cpDay.setSlidingDirection(SwingConstants.SOUTH); if (holidays.containsKey(day)) { cpDay.setBackground(SYSConst.red1[SYSConst.medium1]); } else if (day.getDayOfWeek() == DateTimeConstants.SATURDAY || day.getDayOfWeek() == DateTimeConstants.SUNDAY) { cpDay.setBackground(SYSConst.red1[SYSConst.light3]); } else { cpDay.setBackground(SYSConst.orange1[SYSConst.light3]); } cpDay.setOpaque(true); cpDay.setHorizontalAlignment(SwingConstants.LEADING); cpDay.setStyle(CollapsiblePane.PLAIN_STYLE); cpDay.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpDay.setContentPane(createContentPanel4Day(day)); } }); if (!cpDay.isCollapsed()) { cpDay.setContentPane(createContentPanel4Day(day)); } return cpDay; }