List of usage examples for org.joda.time DateTime minuteOfHour
public Property minuteOfHour()
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()); }//w w w. j a v a2 s. c om 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 w w 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 ww w . j a v a 2 s . 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(); }/*www .ja v a 2 s.c om*/ 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.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());//www . j a va 2 s. co 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 {//from w ww .j a v a 2s . c o 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:org.powertac.hamweather.XmlOutputStructure.java
License:Apache License
private boolean timeToStart(DateTime current) { if (null == batchStartHour) return true; int hour = current.hourOfDay().get(); if (current.minuteOfHour().get() >= 30) hour += 1;// w w w . j a v a2 s . c o m if (hour == batchStartHour) return true; return false; }
From source file:org.shadowmask.core.mask.rules.generalizer.impl.TimestampGeneralizer.java
License:Apache License
@Override public Long generalize(Long timestamp, int hierarchyLevel) { if (timestamp == null) { return null; }/* w w w .jav a 2 s .co m*/ if (hierarchyLevel > ROOT_HIERARCHY_LEVEL || hierarchyLevel < 0) { throw new MaskRuntimeException("Root hierarchy level of MobileGeneralizer is " + ROOT_HIERARCHY_LEVEL + ", invalid input hierarchy level[" + hierarchyLevel + "]"); } if (hierarchyLevel == 0) { return timestamp; } try { DateTime dateTime = new DateTime(timestamp); switch (hierarchyLevel) { // mask ms. case 1: dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()); break; // mask second. case 2: dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); break; // mask minute. case 3: dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); dateTime = dateTime.minuteOfHour().setCopy(0); break; // mask hour. case 4: dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); dateTime = dateTime.minuteOfHour().setCopy(0); dateTime = dateTime.hourOfDay().setCopy(0); break; // mask day. case 5: dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); dateTime = dateTime.minuteOfHour().setCopy(0); dateTime = dateTime.hourOfDay().setCopy(0); dateTime = dateTime.dayOfMonth().setCopy(1); break; // mask month. case 6: dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); dateTime = dateTime.minuteOfHour().setCopy(0); dateTime = dateTime.hourOfDay().setCopy(0); dateTime = dateTime.dayOfMonth().setCopy(1); dateTime = dateTime.monthOfYear().setCopy(1); break; // mask year. case 7: dateTime = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); dateTime = dateTime.minuteOfHour().setCopy(0); dateTime = dateTime.hourOfDay().setCopy(0); dateTime = dateTime.dayOfMonth().setCopy(1); dateTime = dateTime.monthOfYear().setCopy(1); dateTime = dateTime.year().setCopy(1901); break; } return dateTime.getMillis(); } catch (Throwable e) { throw new MaskRuntimeException("Invalid timestamp to generalize:" + timestamp, e); } }
From source file:test.utilities.SemStoreLeakConverter.java
License:Apache License
void processLine(String line, PrintStream ps) throws Exception { if (line == null) return;/*from www . j a va2s . c om*/ 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(""); }
From source file:ums.GenerateTimetable.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from w ww .j ava 2s . c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //processRequest(request, response); response.setContentType("text/html"); PrintWriter out = response.getWriter(); Connection connection = null; Statement stmt = null; try { String queryString; Class.forName(JDBC_DRIVER); connection = DriverManager.getConnection(DB_URL, USER, PASS); System.out.println("Driver loaded"); stmt = connection.createStatement(); int totalRooms = 3; int room = 1; // double time = 9.15; // int dayCount = 0; //String days[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; String deletequeryString = "delete from courseschedule"; ResultSet rset1 = stmt.executeQuery(deletequeryString); queryString = "select * from courses order by section asc"; ResultSet rset = stmt.executeQuery(queryString); //rset.getMetaData().get DateTime startTime = new DateTime(); startTime = startTime.dayOfWeek().setCopy(DateTimeConstants.MONDAY); startTime = startTime.hourOfDay().setCopy("9"); startTime = startTime.minuteOfHour().setCopy("15"); startTime = startTime.secondOfMinute().setCopy("0"); DateTime endTime = new DateTime(); endTime = endTime.dayOfWeek().setCopy(DateTimeConstants.MONDAY); endTime = endTime.hourOfDay().setCopy("21"); endTime = endTime.minuteOfHour().setCopy("15"); endTime = endTime.secondOfMinute().setCopy("0"); DateTimeFormatter fmt = DateTimeFormat.forPattern("h:mm a"); PreparedStatement pst = connection.prepareStatement( "insert into courseschedule(coursenum,section,day,time,location) values(?,?,?,?,?)"); while (rset.next()) { int credit = rset.getInt("credit"); String courseNum = rset.getString("coursenum"); String section = rset.getString("section"); if (room < totalRooms) { if (startTime.hourOfDay().addToCopy(credit).isAfter(endTime)) { room++; if (room == totalRooms) { room = 1; startTime = startTime.dayOfWeek().addToCopy(1); endTime = endTime.dayOfWeek().addToCopy(1); } startTime = startTime.hourOfDay().setCopy("9"); startTime = startTime.minuteOfHour().setCopy("15"); startTime = startTime.secondOfMinute().setCopy("0"); } } String location = "Room" + room; /* if (room < totalRooms) { if (time + credit > 21.15) { room++; if(room==totalRooms){ room = 1; dayCount++; if(dayCount==7){ dayCount = 0; } } time = 9.15; } } String location = "Room" + room; String Time; if(time<12.15){ Time = time + " AM"; }else{ Time = time + " PM"; } */ //stmt.executeUpdate("insert into courseschedule(coursenum,section,day,time,location) values('"+courseNum+"','"+section+"','"+days[dayCount]+"','"+time+"','"+location+"')"); pst.setString(1, courseNum); pst.setString(2, section); pst.setString(3, startTime.dayOfWeek().getAsText()); pst.setString(4, startTime.toString(fmt)); pst.setString(5, location); pst.executeUpdate(); startTime = startTime.hourOfDay().addToCopy(credit); //time = time + credit; } out.println("Inserted Successfully"); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/JSP/viewCourse.jsp"); dispatcher.forward(request, response); } catch (ClassNotFoundException | SQLException ex) { Logger.getLogger(GenerateTimetable.class.getName()).log(Level.SEVERE, null, ex); } finally { try { stmt.close(); connection.close(); } catch (SQLException ex) { Logger.getLogger(GenerateTimetable.class.getName()).log(Level.SEVERE, null, ex); } } }