List of usage examples for org.joda.time DateTime millisOfSecond
public Property millisOfSecond()
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 ww w . j a v a 2s . c o m*/ return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.jevis.commons.driver.DataSourceHelper.java
License:Open Source License
private static DateTime getFolderTime(String name, String[] pathStream) { String compactDateString = getCompactDateString(name, pathStream); String compactDataFormatString = getCompactDateFormatString(name, pathStream); DateTimeFormatter dtf = DateTimeFormat.forPattern(compactDataFormatString); DateTime parseDateTime = dtf.parseDateTime(compactDateString); if (parseDateTime.year().get() == parseDateTime.year().getMinimumValue()) { parseDateTime = parseDateTime.year().withMaximumValue(); }//from ww w . j av a2 s . c o m if (parseDateTime.monthOfYear().get() == parseDateTime.monthOfYear().getMinimumValue()) { parseDateTime = parseDateTime.monthOfYear().withMaximumValue(); } if (parseDateTime.dayOfMonth().get() == parseDateTime.dayOfMonth().getMinimumValue()) { parseDateTime = parseDateTime.dayOfMonth().withMaximumValue(); } if (parseDateTime.hourOfDay().get() == parseDateTime.hourOfDay().getMinimumValue()) { parseDateTime = parseDateTime.hourOfDay().withMaximumValue(); } if (parseDateTime.minuteOfHour().get() == parseDateTime.minuteOfHour().getMinimumValue()) { parseDateTime = parseDateTime.minuteOfHour().withMaximumValue(); } if (parseDateTime.secondOfMinute().get() == parseDateTime.secondOfMinute().getMinimumValue()) { parseDateTime = parseDateTime.secondOfMinute().withMaximumValue(); } if (parseDateTime.millisOfSecond().get() == parseDateTime.millisOfSecond().getMinimumValue()) { parseDateTime = parseDateTime.millisOfSecond().withMaximumValue(); } return parseDateTime; }
From source file:org.kuali.kpme.tklm.utils.TkTestUtils.java
License:Educational Community License
public static Map<DateTime, BigDecimal> getDateToHoursMap(TimeBlock timeBlock, TimeHourDetail timeHourDetail) { Map<DateTime, BigDecimal> dateToHoursMap = new HashMap<DateTime, BigDecimal>(); DateTime beginTime = timeBlock.getBeginDateTime(); DateTime endTime = timeBlock.getEndDateTime(); Days d = Days.daysBetween(beginTime, endTime); int numberOfDays = d.getDays(); if (numberOfDays < 1) { dateToHoursMap.put(timeBlock.getBeginDateTime(), timeHourDetail.getHours()); return dateToHoursMap; }// w w w .ja v a2 s. com DateTime currentTime = beginTime; for (int i = 0; i < numberOfDays; i++) { DateTime nextDayAtMidnight = currentTime.plusDays(1); nextDayAtMidnight = nextDayAtMidnight.hourOfDay().setCopy(12); nextDayAtMidnight = nextDayAtMidnight.minuteOfDay().setCopy(0); nextDayAtMidnight = nextDayAtMidnight.secondOfDay().setCopy(0); nextDayAtMidnight = nextDayAtMidnight.millisOfSecond().setCopy(0); Duration dur = new Duration(currentTime, nextDayAtMidnight); long duration = dur.getStandardSeconds(); BigDecimal hrs = new BigDecimal(duration / 3600, HrConstants.MATH_CONTEXT); dateToHoursMap.put(currentTime, hrs); currentTime = nextDayAtMidnight; } Duration dur = new Duration(currentTime, endTime); long duration = dur.getStandardSeconds(); BigDecimal hrs = new BigDecimal(duration / 3600, HrConstants.MATH_CONTEXT); dateToHoursMap.put(currentTime, hrs); return dateToHoursMap; }
From source file:org.nekorp.workflow.backend.service.reporte.global.RenglonFactoryRG.java
License:Apache License
@Override public RenglonRG build(Servicio data) { RenglonRG r = new RenglonRG(); r.setDatosAuto(factoryAuto.build(data)); r.setDatosBitacora(factoryBitacora.build(data)); r.setDatosCliente(factoryCliente.build(data)); r.setDatosCosto(factoryCosto.build(data)); r.setDatosServicio(factoryServicio.build(data)); Date entradaAutoRaw = r.getDatosBitacora().getFechaIngresoAuto(); if (entradaAutoRaw != null) { DateTime entradaAuto = new DateTime(entradaAutoRaw); entradaAuto = new DateTime(entradaAuto.getYear(), entradaAuto.getMonthOfYear(), entradaAuto.getDayOfMonth(), entradaAuto.hourOfDay().getMinimumValue(), entradaAuto.minuteOfHour().getMinimumValue(), entradaAuto.secondOfMinute().getMinimumValue(), entradaAuto.millisOfSecond().getMinimumValue(), entradaAuto.getZone()); DateTime iniServ = new DateTime(data.getMetadata().getFechaInicio()); iniServ = new DateTime(iniServ.getYear(), iniServ.getMonthOfYear(), iniServ.getDayOfMonth(), iniServ.hourOfDay().getMinimumValue(), iniServ.minuteOfHour().getMinimumValue(), iniServ.secondOfMinute().getMinimumValue(), iniServ.millisOfSecond().getMinimumValue(), iniServ.getZone());/*from w w w . j av a2 s . c o m*/ if (iniServ.isBefore(entradaAuto)) { r.getDatosServicio().setProgramado("X"); } } return r; }
From source file:org.nekorp.workflow.desktop.view.AppLayoutView.java
License:Apache License
private void reporteGlobalButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reporteGlobalButtonActionPerformed try {// ww w.j a v a 2s . co m parametrosReporteGlobal.setFechaInicial(new Date()); parametrosReporteGlobal.setFechaFinal(new Date()); parametrosReporteGlobalDialogFactory.createDialog(mainFrame, true).setVisible(true); if (parametrosReporteGlobal.isEjecutar()) { JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Hojas de clculo", "xlsx"); chooser.setFileFilter(filter); String homePath = System.getProperty("user.home"); File f = new File(new File(homePath + "/Reporte-Global" + ".xlsx").getCanonicalPath()); chooser.setSelectedFile(f); int returnVal = chooser.showSaveDialog(this.mainFrame); if (returnVal == JFileChooser.APPROVE_OPTION) { this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); ParametrosReporteGlobal param = new ParametrosReporteGlobal(); param.setDestination(chooser.getSelectedFile()); DateTime fechaInicial = new DateTime(parametrosReporteGlobal.getFechaInicial()); DateTime fechaFinal = new DateTime(parametrosReporteGlobal.getFechaFinal()); fechaFinal = new DateTime(fechaFinal.getYear(), fechaFinal.getMonthOfYear(), fechaFinal.getDayOfMonth(), fechaFinal.hourOfDay().getMaximumValue(), fechaFinal.minuteOfHour().getMaximumValue(), fechaFinal.secondOfMinute().getMaximumValue(), fechaFinal.millisOfSecond().getMaximumValue(), fechaFinal.getZone()); param.setFechaInicial(fechaInicial); param.setFechaFinal(fechaFinal); this.aplication.generaReporteGlobal(param); } } } catch (IOException ex) { AppLayoutView.LOGGER.error("Exploto al tratar de generar el reporte global", ex); } finally { this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); } }
From source file:test.utilities.SemStoreLeakConverter.java
License:Apache License
void processLine(String line, PrintStream ps) throws Exception { if (line == null) return;//from w ww. ja v a 2 s . co m StringTokenizer tokens = new StringTokenizer(line); if (tokens.countTokens() == 0) return; String dstr = tokens.nextToken(); String tstr = tokens.nextToken(); String datestr = dstr + "T" + tstr; DateTime dtime = new DateTime(datestr); // peel off Info: String info = tokens.nextToken(); // peel off [Event String event = tokens.nextToken(); // grab hold of operation with trailing ] String operation = tokens.nextToken(); int bracket = operation.indexOf(']'); if (bracket > 0) operation = operation.substring(0, bracket); // type of TripleStore in hand String storeType = tokens.nextToken(); // the operation again String op = tokens.nextToken(); // the address String addrStr = tokens.nextToken(); int eq = addrStr.indexOf('='); if (eq > 0) addrStr = addrStr.substring(eq + 1); String memsize = null; // if it's a created line, we might have a trailing , and a mem size out there if (op.equals("created:")) { int comma = addrStr.indexOf(','); if (comma > 0) addrStr = addrStr.substring(0, comma); try { memsize = tokens.nextToken(); if (memsize != null) { eq = memsize.indexOf('='); if (eq > 0) memsize = memsize.substring(eq + 1); } } catch (ArrayIndexOutOfBoundsException e) { } } int month = dtime.monthOfYear().get(); int day = dtime.monthOfYear().get(); int hour = dtime.hourOfDay().get(); int minute = dtime.minuteOfHour().get(); int seconds = dtime.secondOfMinute().get(); int millis = dtime.millisOfSecond().get(); // construct a key String subject = "tstore:" + dtime.year().getAsText() + (month < 10 ? "0" + month : month) + (day < 10 ? "0" + day : day) + (hour < 10 ? "0" + hour : hour) + (minute < 10 ? "0" + minute : minute) + (seconds < 10 ? "0" + seconds : seconds) + "." + (millis < 100 ? "0" : "") + (millis < 10 ? "0" + millis : millis) + "_" + operation; ps.println(subject + "\t" + "tstore:timestamp" + "\t\"" + dtime.toLocalDateTime() + "\"^^xsd:dateTime ."); ps.println(subject + "\t" + "tstore:type" + "\t\"" + operation + "\" ."); ps.println(subject + "\t" + "tstore:address" + "\t\"" + addrStr + "\" ."); if (memsize != null) ps.println(subject + "\t" + "tstore:memsize" + "\t\"" + memsize + "\"^^xsd:integer ."); ps.println(""); }