List of usage examples for org.joda.time DateTime getMinuteOfHour
public int getMinuteOfHour()
From source file:org.gravidence.gravifon.util.DateTimeUtils.java
License:Open Source License
/** * Converts datetime object to array of UTC datetime fields.<p> * Given datetime object is casted to UTC.<p> * Resulting array content is as follows: <code>[yyyy,MM,dd,HH,mm,ss,SSS]</code>. * /*w w w . j a va 2 s . c o m*/ * @param value datetime object * @return array of UTC datetime fields */ public static int[] dateTimeToArray(DateTime value) { int[] result; if (value == null) { result = null; } else { result = new int[7]; DateTime valueUTC = value.toDateTime(DateTimeZone.UTC); result[0] = valueUTC.getYear(); result[1] = valueUTC.getMonthOfYear(); result[2] = valueUTC.getDayOfMonth(); result[3] = valueUTC.getHourOfDay(); result[4] = valueUTC.getMinuteOfHour(); result[5] = valueUTC.getSecondOfMinute(); result[6] = valueUTC.getMillisOfSecond(); } return result; }
From source file:org.graylog2.inputs.random.generators.FakeHttpRawMessageGenerator.java
License:Open Source License
private static Map<String, Object> ingestTimeFields(DateTime ingestTime) { return ImmutableMap.<String, Object>builder().put("ingest_time", ingestTime.toString()) .put("ingest_time_epoch", ingestTime.getMillis()) .put("ingest_time_second", ingestTime.getSecondOfMinute()) .put("ingest_time_minute", ingestTime.getMinuteOfHour()) .put("ingest_time_hour", ingestTime.getHourOfDay()) .put("ingest_time_day", ingestTime.getDayOfMonth()) .put("ingest_time_month", ingestTime.getMonthOfYear()).put("ingest_time_year", ingestTime.getYear()) .build();/* w ww .ja v a2 s.c o m*/ }
From source file:org.hawkular.metrics.core.impl.DateTimeService.java
License:Apache License
public DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }//from ww w .ja va 2s. com return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hawkular.metrics.datetime.DateTimeService.java
License:Apache License
public static DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }//from ww w .j av a 2s .c o m return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hawkular.metrics.tasks.api.AbstractTrigger.java
License:Apache License
protected DateTime getExecutionTime(long time, Duration duration) { DateTime dt = new DateTime(time); Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }/*from w ww . j ava 2s. c o m*/ return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hepaces.surveyfeedbacktestscript.KrogerFeedbackManager.java
/** * Fills in the date and time fields// w ww . j a v a 2 s. c o m * @param date * @param browser */ public static void fillInDateAndTime(DateTime date, WebDriver browser) { logger.debug("Attempting to fill in the date and time inputs @:" + browser.getCurrentUrl()); try { //Date Inputs WebElement monthInput = browser.findElement(By.id(inputMonthId)); WebElement dayInput = browser.findElement(By.id(inputDayId)); WebElement yearInput = browser.findElement(By.id(inputYearId)); //Time Inputs WebElement hourInput = browser.findElement(By.id(inputHourId)); WebElement minuteInput = browser.findElement(By.id(inputMinuteId)); WebElement amPmInput = browser.findElement(By.id(inputAMPM)); //handle date inputs (year is prepopulated, so not handled) numericDropDownHandler(date.getMonthOfYear(), monthInput); numericDropDownHandler(date.getDayOfMonth(), dayInput); //handle time inputs numericDropDownHandler(date.get(DateTimeFieldType.clockhourOfHalfday()), hourInput); numericDropDownHandler(date.getMinuteOfHour(), minuteInput); numericDropDownHandler(date.get(DateTimeFieldType.halfdayOfDay()) + 1, amPmInput); } catch (Exception e) { } }
From source file:org.hortonmachine.gvsig.epanet.core.ChartHelper.java
License:Open Source License
/** * Constructor./*from w w w. ja v a 2 s.c om*/ * * @param valuesMapList the list of ordered maps containing x,y pairs. * @param title the title of the chart. * @param xLabel the x label. * @param yLabel the y label. */ @SuppressWarnings("deprecation") public static void chart(List<LinkedHashMap<DateTime, float[]>> valuesMapList, String title, String xLabel, String yLabel) { List<TimeSeries> seriesList = new ArrayList<TimeSeries>(); for (LinkedHashMap<DateTime, float[]> valuesMap : valuesMapList) { TimeSeries[] series = new TimeSeries[0]; Set<Entry<DateTime, float[]>> entrySet = valuesMap.entrySet(); for (Entry<DateTime, float[]> entry : entrySet) { DateTime date = entry.getKey(); float[] values = entry.getValue(); if (series.length == 0) { series = new TimeSeries[values.length]; for (int i = 0; i < values.length; i++) { series[i] = new TimeSeries(i + 1); } } for (int i = 0; i < values.length; i++) { int sec = date.getSecondOfMinute(); int min = date.getMinuteOfHour(); int hour = date.getHourOfDay(); int day = date.getDayOfMonth(); int month = date.getMonthOfYear(); int year = date.getYear(); series[i].add(new Second(sec, min, hour, day, month, year), values[i]); } } for (TimeSeries timeSeries : series) { seriesList.add(timeSeries); } } TimeSeriesCollection lineDataset = new TimeSeriesCollection(); for (TimeSeries timeSeries : seriesList) { lineDataset.addSeries(timeSeries); } lineDataset.setXPosition(TimePeriodAnchor.MIDDLE); lineDataset.setDomainIsPointsInTime(true); JFreeChart theChart = ChartFactory.createTimeSeriesChart(null, xLabel, yLabel, lineDataset, seriesList.size() > 1, true, true); XYPlot thePlot = theChart.getXYPlot(); ((XYPlot) thePlot).setRenderer(new XYLineAndShapeRenderer()); XYItemRenderer renderer = ((XYPlot) thePlot).getRenderer(); DateAxis axis = (DateAxis) ((XYPlot) thePlot).getDomainAxis(); axis.setDateFormatOverride(dateFormatter); // axis.setAutoRangeMinimumSize(5.0); ValueAxis rangeAxis = ((XYPlot) thePlot).getRangeAxis(); rangeAxis.setAutoRangeMinimumSize(5.0); for (int i = 0; i < seriesList.size(); i++) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(i, true); ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(i, true); } ChartPanel chartPanel = new ChartPanel(theChart, false); chartPanel.setPreferredSize(new Dimension(600, 500)); chartPanel.setHorizontalAxisTrace(false); chartPanel.setVerticalAxisTrace(false); WindowManager windowManager = ToolsSwingLocator.getWindowManager(); windowManager.showWindow(chartPanel, title, MODE.WINDOW); }
From source file:org.iexhub.connectors.PDQQueryManager.java
License:Apache License
/** * @param qUQIIN000003UV01//from ww w.ja v a 2s . c om */ private void setCreationTime(QUQIIN000003UV01Type qUQIIN000003UV01) { DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder timeBuilder = new StringBuilder(); timeBuilder.append(dt.getYear()); timeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); timeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); timeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); timeBuilder.append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); timeBuilder.append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(timeBuilder.toString()); qUQIIN000003UV01.setCreationTime(creationTime); }
From source file:org.iexhub.connectors.PDQQueryManager.java
License:Apache License
/** * @param pRPA_IN201305UV02/*from w w w.ja v a 2s .co m*/ */ private void setCreationTime(PRPAIN201305UV02 pRPA_IN201305UV02) { DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder timeBuilder = new StringBuilder(); timeBuilder.append(dt.getYear()); timeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); timeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); timeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); timeBuilder.append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); timeBuilder.append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(timeBuilder.toString()); pRPA_IN201305UV02.setCreationTime(creationTime); }
From source file:org.iexhub.connectors.PIXManager.java
License:Apache License
/** * @param patientId//from ww w .j a v a2s . c o m * @param domainOID * @param populateDataSource * @return * @throws IOException */ public PRPAIN201310UV02 patientRegistryGetIdentifiers(String patientId, String domainOID, boolean populateDataSource) throws IOException { if ((patientId == null) || (patientId.length() == 0)) { throw new PatientIdParamMissingException("PatientId parameter is required"); } PRPAIN201309UV02 pRPA_IN201309UV02 = new PRPAIN201309UV02(); // ITS version... pRPA_IN201309UV02.setITSVersion("XML_1.0"); // ID... II messageId = new II(); messageId.setRoot(iExHubDomainOid); messageId.setExtension(UUID.randomUUID().toString()); pRPA_IN201309UV02.setId(messageId); // Creation time... DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder creationTimeBuilder = new StringBuilder(); creationTimeBuilder.append(dt.getYear()); creationTimeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); creationTimeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); creationTimeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); creationTimeBuilder .append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); creationTimeBuilder .append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(creationTimeBuilder.toString()); pRPA_IN201309UV02.setCreationTime(creationTime); // Interaction ID... II interactionId = new II(); interactionId.setRoot("2.16.840.1.113883.1.6"); interactionId.setExtension("PRPA_IN201309UV02"); pRPA_IN201309UV02.setInteractionId(interactionId); // Processing code... CS processingCode = new CS(); processingCode.setCode("P"); pRPA_IN201309UV02.setProcessingCode(processingCode); // Processing mode code... CS processingModeCode = new CS(); processingModeCode.setCode("T"); pRPA_IN201309UV02.setProcessingModeCode(processingModeCode); // Accept ack code... CS acceptAckCode = new CS(); acceptAckCode.setCode("AL"); pRPA_IN201309UV02.setAcceptAckCode(acceptAckCode); // Create receiver... MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver(); receiver.setTypeCode(CommunicationFunctionType.RCV); MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device(); receiverDevice.setClassCode(EntityClassDevice.DEV); receiverDevice.setDeterminerCode("INSTANCE"); II receiverDeviceId = new II(); receiverDeviceId.setRoot(receiverApplicationName); receiverDevice.getId().add(receiverDeviceId); receiver.setDevice(receiverDevice); pRPA_IN201309UV02.getReceiver().add(receiver); // Create sender... MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender(); sender.setTypeCode(CommunicationFunctionType.SND); MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device(); senderDevice.setClassCode(EntityClassDevice.DEV); senderDevice.setDeterminerCode("INSTANCE"); II senderDeviceId = new II(); senderDeviceId.setRoot(PIXManager.iExHubSenderDeviceId); senderDevice.getId().add(senderDeviceId); sender.setDevice(senderDevice); pRPA_IN201309UV02.setSender(sender); // Create AuthorOrPerformer... QUQIMT021001UV01AuthorOrPerformer authorOrPerformer = new QUQIMT021001UV01AuthorOrPerformer(); authorOrPerformer.setTypeCode(XParticipationAuthorPerformer.fromValue("AUT")); COCTMT090100UV01AssignedPerson assignedPerson = new COCTMT090100UV01AssignedPerson(); assignedPerson.setClassCode("ASSIGNED"); II assignedPersonId = new II(); assignedPersonId.setRoot(PIXManager.iExHubDomainOid); assignedPersonId.setExtension("IExHub"); assignedPerson.getId().add(assignedPersonId); authorOrPerformer.setAssignedPerson( objectFactory.createQUQIMT021001UV01AuthorOrPerformerAssignedPerson(assignedPerson)); // Create QueryByParameter... PRPAMT201307UV02QueryByParameter queryByParam = new PRPAMT201307UV02QueryByParameter(); II queryId = new II(); queryId.setRoot(queryIdOid); queryId.setExtension(UUID.randomUUID().toString()); queryByParam.setQueryId(queryId); CS responsePriorityCode = new CS(); responsePriorityCode.setCode("I"); queryByParam.setResponsePriorityCode(responsePriorityCode); CS statusCode = new CS(); statusCode.setCode("new"); queryByParam.setStatusCode(statusCode); // Create ParameterList... PRPAMT201307UV02ParameterList paramList = new PRPAMT201307UV02ParameterList(); if (populateDataSource) { // Create DataSource... PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource(); II dataSourceId = new II(); dataSourceId.setRoot(dataSourceOid); dataSource.getValue().add(dataSourceId); ST dataSourceSemanticsText = new ST(); dataSourceSemanticsText.getContent().add("DataSource.id"); dataSource.setSemanticsText(dataSourceSemanticsText); paramList.getDataSource().add(dataSource); } // Create PatientIdentifier... PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier(); II patientIdentifierId = new II(); patientIdentifierId.setRoot(domainOID); patientIdentifierId.setExtension(patientId); patientIdentifier.getValue().add(patientIdentifierId); ST patientIdentifierSemanticsText = new ST(); patientIdentifierSemanticsText.getContent().add("Patient.Id"); patientIdentifier.setSemanticsText(patientIdentifierSemanticsText); paramList.getPatientIdentifier().add(patientIdentifier); queryByParam.setParameterList(paramList); // Create ControlActProcess... PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlAct = new PRPAIN201309UV02QUQIMT021001UV01ControlActProcess(); CD controlActProcessCode = new CD(); controlActProcessCode.setCode("PRPA_TE201309UV02"); controlActProcessCode.setCodeSystem("2.16.840.1.113883.1.6"); controlAct.setCode(controlActProcessCode); controlAct.setClassCode(ActClassControlAct.CACT); controlAct.setMoodCode(XActMoodIntentEvent.EVN); controlAct.getAuthorOrPerformer().add(authorOrPerformer); controlAct.setQueryByParameter(objectFactory .createPRPAIN201309UV02QUQIMT021001UV01ControlActProcessQueryByParameter(queryByParam)); pRPA_IN201309UV02.setControlActProcess(controlAct); OMElement requestElement = pixManagerStub.toOM(pRPA_IN201309UV02, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201301UV02")), new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201309UV02")); String queryText = requestElement.toString(); UUID logMsgId = null; if (logPixRequestMessages) { logMsgId = UUID.randomUUID(); Files.write(Paths.get(logOutputPath + logMsgId.toString() + "_PIXGetIdentifiersRequest.xml"), requestElement.toString().getBytes()); } logIti45AuditMsg(queryText, patientId + "^^^&" + domainOID + "&ISO"); PRPAIN201310UV02 response = pixManagerStub.pIXManager_PRPA_IN201309UV02(pRPA_IN201309UV02); if (logPixResponseMessages) { OMElement responseElement = pixManagerStub.toOM(response, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201310UV02")), new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201310UV02")); Files.write(Paths .get(logOutputPath + ((logMsgId == null) ? UUID.randomUUID().toString() : logMsgId.toString()) + "_PIXGetIdentifiersResponse.xml"), responseElement.toString().getBytes()); } return response; }