List of usage examples for java.util Calendar DAY_OF_YEAR
int DAY_OF_YEAR
To view the source code for java.util Calendar DAY_OF_YEAR.
Click Source Link
get
and set
indicating the day number within the current year. From source file:com.lp.server.fertigung.ejbfac.FertigungFacBean.java
public Integer holeTageslos(Integer lagerIId, String mandantCNr, int iStandarddurchlaufzeit, boolean bSofortverbrauch, TheClientDto theClientDto) { Integer losIId = null;// w ww . ja va2s.c om TageslosDto tageslosDto = null; try { tageslosDto = getKuecheFac().tageslosFindByLagerIIdBSofortverbrauch(lagerIId, Helper.boolean2Short(bSofortverbrauch)); } catch (RemoteException e) { throwEJBExceptionLPRespectOld(e); } if (tageslosDto != null) { // Nun das erste ausgegebene Los mit der angegebenen Kostenstelle // des heutigen Tages suchen Session session = FLRSessionFactory.getFactory().openSession(); String sQuery3 = "FROM FLRLosReport AS l WHERE l.kostenstelle_i_id=" + tageslosDto.getKostenstelleIId() + " AND l.stueckliste_i_id IS NULL AND l.status_c_nr IN('" + FertigungFac.STATUS_IN_PRODUKTION + "','" + FertigungFac.STATUS_TEILERLEDIGT + "') AND l.t_produktionsbeginn='" + Helper.formatDateWithSlashes(new java.sql.Date(System.currentTimeMillis())) + "' "; if (bSofortverbrauch) { sQuery3 += " AND l.flrfertigungsgruppe.c_bez='" + StuecklisteFac.FERTIGUNGSGRUPPE_SOFORTVERBRAUCH + "' "; } else { sQuery3 += " AND l.flrfertigungsgruppe.c_bez NOT IN('" + StuecklisteFac.FERTIGUNGSGRUPPE_SOFORTVERBRAUCH + "') "; } sQuery3 += " ORDER BY l.t_produktionsbeginn DESC"; org.hibernate.Query hquery3 = session.createQuery(sQuery3); hquery3.setMaxResults(1); List<?> resultList3 = hquery3.list(); Iterator<?> resultListIterator3 = resultList3.iterator(); if (resultListIterator3.hasNext()) { FLRLosReport rep = (FLRLosReport) resultListIterator3.next(); losIId = rep.getI_id(); } else { // Wenn keines gefunden wurde, dann ein neues anlegen Timestamp tHeute = Helper.cutTimestamp(new Timestamp(System.currentTimeMillis())); Calendar cTemp = Calendar.getInstance(); cTemp.set(Calendar.DAY_OF_YEAR, cTemp.get(Calendar.DAY_OF_YEAR) + iStandarddurchlaufzeit); LosDto losDto = new LosDto(); losDto.setTProduktionsbeginn(new java.sql.Date(tHeute.getTime())); losDto.setTProduktionsende(new java.sql.Date(cTemp.getTimeInMillis())); losDto.setKostenstelleIId(tageslosDto.getKostenstelleIId()); losDto.setMandantCNr(mandantCNr); losDto.setNLosgroesse(new BigDecimal(1)); try { FertigungsgruppeDto[] fgDto = getStuecklisteFac().fertigungsgruppeFindByMandantCNr(mandantCNr, theClientDto); if (fgDto != null && fgDto.length > 0) { losDto.setFertigungsgruppeIId(fgDto[0].getIId()); } if (bSofortverbrauch) { Fertigungsgruppe fertigungsgruppe; try { Query query = em.createNamedQuery("FertigungsgruppefindByMandantCNrCBez"); query.setParameter(1, mandantCNr); query.setParameter(2, StuecklisteFac.FERTIGUNGSGRUPPE_SOFORTVERBRAUCH); fertigungsgruppe = (Fertigungsgruppe) query.getSingleResult(); losDto.setFertigungsgruppeIId(fertigungsgruppe.getIId()); } catch (javax.persistence.NoResultException e) { FertigungsgruppeDto fertigungsgruppeDto = new FertigungsgruppeDto(); fertigungsgruppeDto.setCBez(StuecklisteFac.FERTIGUNGSGRUPPE_SOFORTVERBRAUCH); fertigungsgruppeDto.setISort(getStuecklisteFac().getNextFertigungsgruppe(theClientDto)); Integer i = getStuecklisteFac().createFertigungsgruppe(fertigungsgruppeDto, theClientDto); losDto.setFertigungsgruppeIId(i); } } MandantDto mandantDto = getMandantFac().mandantFindByPrimaryKey(mandantCNr, theClientDto); losDto.setPartnerIIdFertigungsort(mandantDto.getPartnerIId()); LagerDto lagerDtoAbbuchungslager = getLagerFac() .lagerFindByPrimaryKey(tageslosDto.getLagerIIdAbbuchung()); String projekt = "Tageslos " + Helper.formatDatum(tHeute, theClientDto.getLocUi()) + " " + lagerDtoAbbuchungslager.getCNr(); losDto.setCProjekt(projekt); losDto.setLagerIIdZiel(getLagerFac().getHauptlagerDesMandanten(theClientDto).getIId()); losIId = getFertigungFac().createLos(losDto, theClientDto).getIId(); getFertigungFac().gebeLosAus(losIId, true, false, theClientDto, null); } catch (RemoteException e) { throwEJBExceptionLPRespectOld(e); } } session.close(); } return losIId; }
From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java
public void buscaAtendimento() { String status = "'ABERTO','INICIADO','PENDENTE'"; Integer idtecnico = new UsuarioLogadoBeans().getIdusuario(); Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -30); Date ini = c.getTime();/*from w w w .j ava 2 s.c om*/ Date fin = new Timestamp(new Date().getTime()); String campo = "dtabertura"; List<AtendimentoBeans> labt = new ArrayList<>(); DefaultTableModel tabelaatendimento = (DefaultTableModel) jTatendimento.getModel(); try { labt = new AtendimentoDao().getAtendimento(getTipoSelected(), status, idtecnico, new UsuarioLogadoBeans().getVchamados(), ini, fin, getTipoData()); if (!caparaArrayList(labt, lab)) { lab = labt; tabelaatendimento.setNumRows(0); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); TableCellRenderer renderer = new PintarLinhasTabelaAtend(false); jTatendimento.setDefaultRenderer(jTatendimento.getColumnClass(0), renderer); for (AtendimentoBeans ab : lab) { tabelaatendimento.addRow( new Object[] { ab.getIDATENDIMENTO(), ab.getRazao(), sdf.format(ab.getDTABERTURA()), ab.getTecniconome(), ab.getAberturanome(), ab.getSTATUS(), ab.getTIPO() }); } } } catch (SQLException ex) { lab.clear(); tabelaatendimento.setNumRows(0); //Logger.getLogger(ViewListaAtendimento.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.square.adherent.noyau.service.implementations.AdherentServiceImpl.java
private Integer getAge(Calendar dateNaissance) { final Integer ageMillesime = getAgeMillesime(dateNaissance); final Integer age = Calendar.getInstance().get(Calendar.DAY_OF_YEAR) > dateNaissance .get(Calendar.DAY_OF_YEAR) ? ageMillesime : ageMillesime - 1; return age;/*w w w. j a v a 2s. c om*/ }
From source file:gskproject.Analyze.java
private void btnPersonGraphActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPersonGraphActionPerformed //System.out.println(); if (tblPersonVise.getSelectedRow() != -1) { String username = tablePersonWise.get(tblPersonVise.getSelectedRow()).get(0).toString(); int userID = dbOps.getUserID(username); java.sql.Date from;/*from w ww .j a v a 2 s .c om*/ java.sql.Date to; if (dtPFrom.getDate() == null && dtPTo.getDate() == null) { from = null; to = null; } else if (dtPFrom.getDate() == null) { from = null; to = new java.sql.Date(dtPTo.getDate().getTime()); } else if (dtPTo.getDate() == null) { from = new java.sql.Date(dtPFrom.getDate().getTime()); to = null; } else { from = new java.sql.Date(dtPFrom.getDate().getTime()); to = new java.sql.Date(dtPTo.getDate().getTime()); } Vector<Vector> eachPersonDates = new Vector<Vector>(); eachPersonDates = dbOps.getEachPersonObservation(from, to, userID); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart chart = null; Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance(); for (Vector<Object> row : eachPersonDates) { start.setTime((Date) row.get(1)); end.setTime((Date) row.get(2)); dataset.addValue(end.get(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR), "First Aid", row.get(0).toString()); } chart = ChartFactory.createLineChart("All Departments VS All Accident Types", "Observation ID", "Days", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame(username + " Chart", chart); frame.setSize(700, 500); frame.setVisible(true); } else { JOptionPane.showMessageDialog(this, "Please select a person using table!"); } }
From source file:nl.strohalm.cyclos.services.transactions.PaymentServiceImpl.java
@Override public StatisticalResultDTO getSimulateConversionGraph(final ConversionSimulationDTO input) { final LocalSettings localSettings = settingsService.getLocalSettings(); final byte precision = (byte) localSettings.getPrecision().getValue(); // get series final TransactionFeePreviewForRatesDTO temp = simulateConversion(input); final int series = temp.getFees().size(); // get range of points, but without values for A < 0 BigDecimal initialARate = null; RatesResultDTO rates = new RatesResultDTO(); if (input.isUseActualRates()) { rates = rateService.getRatesForTransferFrom(input.getAccount(), input.getAmount(), null); rates.setDate(input.getDate());/* w ww .j ava 2s .c om*/ initialARate = rates.getaRate(); } else { initialARate = input.getArate(); } // lowerlimit takes care that values for A < 0 are left out of the graph final Double lowerLimit = (initialARate == null) ? null : initialARate.negate().doubleValue(); final Number[] xRange = GraphHelper.getOptimalRangeAround(0, 33, 0, 0.8, lowerLimit); // Data structure to build the table final Number[][] tableCells = new Number[xRange.length][series]; // initialize series names and x labels final String[] seriesNames = new String[series]; final byte[] seriesOrder = new byte[series]; final Calendar[] xPointDates = new Calendar[xRange.length]; final Calendar now = Calendar.getInstance(); BigDecimal inputARate = temp.getARate(); BigDecimal inputDRate = temp.getDRate(); // assign data for (int i = 0; i < xRange.length; i++) { final ConversionSimulationDTO inputPointX = (ConversionSimulationDTO) input.clone(); final Calendar date = (Calendar) ((input.isUseActualRates()) ? input.getDate().clone() : now.clone()); date.add(Calendar.DAY_OF_YEAR, xRange[i].intValue()); xPointDates[i] = date; // Set useActualRates for this input to false, otherwise simulateConversion will use the account's the balance and rates of that date, and // we don't want that. inputPointX.setUseActualRates(false); if (inputARate != null) { final BigDecimal aRate = inputARate.add(new BigDecimal(xRange[i].doubleValue())); inputPointX.setArate(aRate); } if (inputDRate != null) { final BigDecimal dRate = inputDRate.subtract(new BigDecimal(xRange[i].doubleValue())); inputPointX.setDrate(dRate); } final TransactionFeePreviewDTO tempResult = simulateConversion(inputPointX); int j = 0; for (final TransactionFee fee : tempResult.getFees().keySet()) { tableCells[i][j] = new StatisticalNumber(tempResult.getFees().get(fee).doubleValue(), precision); byte index; switch (fee.getChargeType()) { case D_RATE: index = 2; break; case A_RATE: case MIXED_A_D_RATES: index = 3; break; default: index = 1; break; } seriesOrder[j] = index; seriesNames[j++] = fee.getName(); } } // create the graph object final StatisticalResultDTO result = new StatisticalResultDTO(tableCells); result.setBaseKey("conversionSimulation.result.graph"); result.setHelpFile("account_management"); // date labels along x-axis final String[] rowKeys = new String[xRange.length]; Arrays.fill(rowKeys, ""); result.setRowKeys(rowKeys); for (int i = 0; i < rowKeys.length; i++) { final String rowHeader = localSettings.getDateConverterForGraphs().toString(xPointDates[i]); result.setRowHeader(rowHeader, i); } // mark the actual date upon which the x-axis is based as a vertical line final Calendar baseDate = (input.isUseActualRates()) ? (Calendar) input.getDate().clone() : now; final String baseDateString = localSettings.getDateConverterForGraphs().toString(baseDate); final Marker[] markers = new Marker[1]; markers[0] = new CategoryMarker(baseDateString); markers[0].setPaint(Color.ORANGE); final String todayString = localSettings.getDateConverterForGraphs().toString(now); if (todayString.equals(baseDateString)) { markers[0].setLabel("global.today"); } result.setDomainMarkers(markers); // Series labels indicate fee names final String[] columnKeys = new String[series]; Arrays.fill(columnKeys, ""); result.setColumnKeys(columnKeys); for (int j = 0; j < columnKeys.length; j++) { result.setColumnHeader(seriesNames[j], j); } // order the series result.orderSeries(seriesOrder); final TransferType tt = fetchService.fetch(input.getTransferType(), RelationshipHelper.nested(TransferType.Relationships.FROM, AccountType.Relationships.CURRENCY)); result.setYAxisUnits(tt.getCurrency().getSymbol()); result.setShowTable(false); result.setGraphType(StatisticalResultDTO.GraphType.STACKED_AREA); return result; }
From source file:org.botlibre.util.Utils.java
public static String displayTimestamp(Date date) { if (date == null) { return ""; }/*from w w w .ja v a 2s . c o m*/ StringWriter writer = new StringWriter(); Calendar today = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); if (calendar.get(Calendar.YEAR) == today.get(Calendar.YEAR) && calendar.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) { writer.write("Today"); } else if (calendar.get(Calendar.YEAR) == today.get(Calendar.YEAR) && calendar.get(Calendar.DAY_OF_YEAR) == (today.get(Calendar.DAY_OF_YEAR) - 1)) { writer.write("Yesterday"); } else { writer.write(calendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US)); writer.write(" "); writer.write(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH))); if (calendar.get(Calendar.YEAR) != today.get(Calendar.YEAR)) { writer.write(" "); writer.write(String.valueOf(calendar.get(Calendar.YEAR))); } } writer.write(", "); writer.write(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY))); writer.write(":"); if (calendar.get(Calendar.MINUTE) < 10) { writer.write("0"); } writer.write(String.valueOf(calendar.get(Calendar.MINUTE))); return writer.toString(); }
From source file:com.eryansky.common.utils.SysUtils.java
/** * // ww w.ja va2s . co m * * @param hour * * @return */ public static String getAccDate(int hour) { Calendar calendar = Calendar.getInstance(); if (calendar.get(Calendar.HOUR_OF_DAY) >= hour) { calendar.add(Calendar.DAY_OF_YEAR, 1); } return dateFormat(calendar.getTime(), "yyyyMMdd"); }
From source file:com.eryansky.common.utils.SysUtils.java
public static String getAccDateShort(int hour) { Calendar calendar = Calendar.getInstance(); if (calendar.get(Calendar.HOUR_OF_DAY) >= hour) { calendar.add(Calendar.DAY_OF_YEAR, 1); }//w ww . j a va 2s . c o m return dateFormat(calendar.getTime(), "yyMMdd"); }
From source file:ProtocolRunner.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // Single Value Dialog OK Button //from w w w. jav a2s. com // this method only handles tcp protocols, for udp protocols, another // method is used if(jTabbedPane1.getSelectedIndex() == 1) { // means we are in udp tab udpSingleValOKButton(); return; } String valueText = singleValueField.getText(); String valueLabel = singleValueLabel.getText(); int selection = tcpSelectionBox.getSelectedIndex(); try{ if(selection == 4) { // means handling FTP if("New Directory:".equals(valueLabel)) { // means CWD ((FTPClient)tcpClient).changeWorkingDirectory(valueText); } else if( "New Directory Name:".equals(valueLabel)) { // means make new directory ((FTPClient)tcpClient).makeDirectory(valueText); } else if( "Full path to local file:".equals( valueLabel)) { // means uploading file FileInputStream input = new FileInputStream(valueText); ((FTPClient)tcpClient).storeFile( new File(valueText).getName(), input); input.close(); } else if("Remote file:".equals(valueLabel)) { // means downloading a file FileOutputStream output = new FileOutputStream( System.getProperty("user.dir") + System.getProperty("file.separator") + valueText); ((FTPClient)tcpClient).retrieveFile(valueText, output); output.close(); } tcpServerResponse.append( ((FTPClient)tcpClient).getReplyString() + "\r\n"); } else if(selection == 5) { // means handling NNTP if("Full or part name of group:".equals(valueLabel)) { // means getting new news of a group // create a query to get all new messages in this group // since yesterday GregorianCalendar today = new GregorianCalendar(); today.roll(Calendar.DAY_OF_YEAR, false); NewGroupsOrNewsQuery query = new NewGroupsOrNewsQuery(today, false); query.addDistribution(valueText); String[] result = ((NNTPClient)tcpClient).listNewNews(query); tcpServerResponse.append( ((NNTPClient)tcpClient).getReplyString() + "\r\n"); // in case the NEWNEWS cmmand is disabled if(result == null) return; for(int i=0; i<result.length; i++) { tcpServerResponse.append( result[i] + "\r\n"); } } else if("Enter message id:".equals(valueLabel)) { // means getting a message based on id DotTerminatedMessageReader reader = (DotTerminatedMessageReader) ((NNTPClient)tcpClient).retrieveArticle( "<" + valueText + ">"); tcpServerResponse.append( ((NNTPClient)tcpClient).getReplyString() + "\r\n"); if(reader == null) return; BufferedReader buffReader = new BufferedReader(reader); String lineRead; while((lineRead = buffReader.readLine()) != null) { tcpServerResponse.append(lineRead + "\r\n"); } } } else if(selection == 6) { // means handling pop3 if("Enter message number:".equals(valueLabel)) { // means getting a message based on number DotTerminatedMessageReader reader = (DotTerminatedMessageReader) ((POP3Client)tcpClient).retrieveMessage( Integer.parseInt(valueText)); tcpServerResponse.append( ((POP3Client)tcpClient).getReplyString() + "\r\n"); if(reader == null) return; BufferedReader buffReader = new BufferedReader(reader); String lineRead; while((lineRead = buffReader.readLine()) != null) { tcpServerResponse.append(lineRead + "\r\n"); } } else if("Enter message number to delete:".equals(valueLabel)){ // means deleting a message based on id ((POP3Client)tcpClient).deleteMessage( Integer.parseInt(valueText)); tcpServerResponse.append( ((POP3Client)tcpClient).getReplyString() + "\r\n"); } } else if(selection == 2) { // is echo BufferedReader reader = new BufferedReader( new InputStreamReader( ((EchoTCPClient)tcpClient).getInputStream())); PrintWriter writer = new PrintWriter( new OutputStreamWriter( ((EchoTCPClient)tcpClient).getOutputStream()), true); // write to the server writer.println(valueText); // read from the server tcpServerResponse.append(reader.readLine()); // streams are not closed here as there is no provision for the // user to send another stream of data. Thus the user has to // close the connection, which cleans up open streams. } else if(selection == 3) { // is finger tcpServerResponse.setText( ((FingerClient)tcpClient).query(false, valueText)); } else if(selection == 9) { // is whois tcpServerResponse.setText( ((WhoisClient)tcpClient).query(valueText)); } }catch(IOException ioex) { showError(ioex.getMessage()); return; } finally { singleValueField.setText(""); singleValueDialog.setVisible(false); } }