List of usage examples for java.util Calendar compareTo
private int compareTo(long t)
From source file:com.hrbb.loan.pos.biz.backstage.inter.impl.LoanPosCreditApplyBackStageBizImpl.java
/** * App??? ./*w w w . j a v a 2 s .co m*/ * * @param loanId * @param custId * @param paperKind * @param paperId * @param custName * @param beginDate * @param endDate * @return */ public List<Map<String, Object>> queryCreditApplyDetailByZzApp(String loanId, String custId, String paperKind, String paperId, String custName, String beginDate, String endDate) { Boolean flag = false; Map<String, Object> queryMap = Maps.newHashMap(); try { // ?? if (!StringUtil.isEmpty(loanId)) { queryMap.put("loanId", loanId); } if (!StringUtil.isEmpty(custId)) { queryMap.put("custId", custId); } if (!StringUtil.isEmpty(paperId)) { queryMap.put("paperKind", paperKind); queryMap.put("paperId", paperId); } if (!StringUtil.isEmpty(beginDate)) { queryMap.put("beginDate", new Timestamp(DateUtil.getTimeStamp(beginDate))); } if (!StringUtil.isEmpty(endDate)) { queryMap.put("endDate", new Timestamp(DateUtil.getTimeStamp(endDate))); } // ? List<Map<String, Object>> returnList = loanPosCreditApplyService.queryListByZzApp(queryMap); if (!returnList.isEmpty()) { // ?? for (Map<String, Object> map : returnList) { // if (ReviewNoteConstants.APPLYSTATUS_CODE_21.equals(map.get("apprstate")) || ReviewNoteConstants.APPLYSTATUS_CODE_32.equals(map.get("apprstate"))) { TCreditApplyAprvInfo tCreditApplyAprvInfoKey = new TCreditApplyAprvInfo(); tCreditApplyAprvInfoKey.setLoanId((String) map.get("loanid")); tCreditApplyAprvInfoKey.setApprResult(ReviewNoteConstants.APPRRESULT_CODE_31); TCreditApplyAprvInfo tCreditApplyAprvInfo = tCreditApplyAprvInfoDao .selectLastOne(tCreditApplyAprvInfoKey); if (tCreditApplyAprvInfo != null) { map.put("additspec", tCreditApplyAprvInfo.getNeedReason()); map.put("imgadditdetail", tCreditApplyAprvInfo.getNeedInforCodes()); } // map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "D", 14)); // ? } else if (ReviewNoteConstants.APPLYSTATUS_CODE_92.equals(map.get("apprstate"))) { TCreditApplyAprvInfo tCreditApplyAprvInfoKey = new TCreditApplyAprvInfo(); tCreditApplyAprvInfoKey.setLoanId((String) map.get("loanid")); tCreditApplyAprvInfoKey.setApprResult(ReviewNoteConstants.APPRRESULT_CODE_20); TCreditApplyAprvInfo tCreditApplyAprvInfo = tCreditApplyAprvInfoDao .selectLastOne(tCreditApplyAprvInfoKey); if (tCreditApplyAprvInfo != null) { //20150728 guoyu ???? //map.put("refusereason", tCreditApplyAprvInfo.getApprInfoExt()); map.put("refusereason", businessDictionaryService .getApprInfoExtMsg(tCreditApplyAprvInfo.getApprInfoExt())); } // map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "M", 3)); // } else if (ReviewNoteConstants.APPLYSTATUS_CODE_90.equals(map.get("apprstate"))) { TApproveResult tApproveResult = tApproveResultDao .selectByLoanId((String) map.get("loanid")); if (tApproveResult != null) { map.put("appmaxcred", tApproveResult.getApproveAmount()); // ? map.put("apptterm", tApproveResult.getApproveTerm()); // ? map.put("interate", tApproveResult.getApproveInterest()); // map.put("appenddate", tApproveResult.getExpiryDate() == null ? "" : DateFormatUtils.format(tApproveResult.getExpiryDate(), "yyyyMMdd")); // ? } TContractManagement tContractInfo = tContractInfoDao .selectContractInfoByLoanId((String) map.get("loanid")); if (tContractInfo != null && "05|09".indexOf(tContractInfo.getAgreementStatus()) < 0) { map.put("apprstate", "191"); // 191, Calendar calNow = Calendar.getInstance(); logger.debug(":" + calNow.getTime()); Calendar cal = Calendar.getInstance(); cal.setTime(tContractInfo.getEndDate()); cal.add(Calendar.MONTH, -1); logger.debug("????" + cal.getTime()); Calendar calEnd = Calendar.getInstance(); logger.debug("???:" + calEnd.getTime()); calEnd.setTime(tContractInfo.getEndDate()); //???? if (tContractInfo.getAgreementStatus() != null && "06".equals(tContractInfo.getAgreementStatus())) { logger.debug(loanId + "?"); if (calNow.compareTo(cal) >= 0 && calNow.compareTo(calEnd) < 0) { flag = true; } } } // map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "D", 7)); } else if ("10|20|30|31|33|34".indexOf((String) map.get("apprstate")) > -1) { // map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "D", 2)); } if (flag) { map.put("reloanflag", "Y"); // ? } else { map.put("reloanflag", "N"); // ?? } } } return returnList; } catch (Exception e) { logger.error("App??? :[]", e.getMessage()); return null; } }
From source file:securify.ububble.securify.fragments.Payment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_payment, container, false); ButterKnife.inject(this, view); SharedPreferences settings = getActivity().getSharedPreferences("pref", 0); userId = settings.getString(Constantes.USER_ID, ""); finder = new TextFinder(getActivity()); for (int element : botones) { view.findViewById(element).setOnClickListener(this); }//from ww w. j av a 2 s .c om bp = new BillingProcessor(getActivity(), LICENSEKEY, new BillingProcessor.IBillingHandler() { JSONObject json = null; @Override public void onProductPurchased(String s, TransactionDetails transactionDetails) { if (transactionDetails.productId.equals(finder.getText(OPC.ID_SUBSCRIPTION_ANNUAL))) { try { Calendar calendario = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); json = new JSONObject(transactionDetails.purchaseInfo.responseData); txtRegalaronSecurify.setText(json.getInt("purchaseTime")); RequestParams params = new RequestParams(); params.put("transaction_id", json.getString("orderId")); params.put("amount", 23.99); params.put("currency", "USD"); calendario.setTime(new Date(json.getLong("purchaseTime"))); String s_date = format.format(calendario.getTime()); calendario.add(Calendar.MONTH, 1); String e_date = format.format(calendario.getTime()); params.put("d_start", s_date); params.put("d_end", e_date); params.put("type", 2); params.put("hash", new ConvertToMD5(23.99 + userId + json.getString("orderId") + "USD" + 2 + Constantes.AMX_SECRET + e_date + s_date)); params.put("user_app_billing", contentPrincipal.userEmail); Client.post("users/" + userId + "/p", null, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { } }, getActivity()); } catch (JSONException e) { } } else if (transactionDetails.productId.equals(finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL))) { txtRegalaronSecurify.setText(transactionDetails.purchaseInfo.responseData); } else if (transactionDetails.productId.equals(finder.getText(OPC.ID_SUBSCRIPTION_TRAVELER))) { txtRegalaronSecurify.setText(transactionDetails.purchaseInfo.responseData); } } @Override public void onPurchaseHistoryRestored() { } @Override public void onBillingError(int i, Throwable throwable) { showToast("onBillingError: " + Integer.toString(i)); } @Override public void onBillingInitialized() { readyToPurchase = true; } }); Client.get("users/" + userId + "/state", null, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { userActive = response.getBoolean("user_active"); remainingDays = response.getInt("remaining_days"); Client.get("users/" + userId, null, new JsonHttpResponseHandler() { JSONObject json = null; Calendar calendario = Calendar.getInstance(); DateFormat formato = DateFormat.getDateInstance(DateFormat.FULL); @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { name = response.getString("name"); if (remainingDays < 0) { txtRegalaronSecurify.setText( String.format(finder.getText(OPC.TXT_SUSCRIPCION_CADUCADA), name)); } else if (remainingDays > 0) { String texto = remainingDays > 1 ? String.format(finder.getText(OPC.TXT_FREE_TRIALMODE_MORE), name, remainingDays + "") : String.format(finder.getText(OPC.TXT_FREE_TRIALMODE_SIMPLE), name, remainingDays + ""); txtRegalaronSecurify.setText(texto); view.findViewById(R.id.btn_pagar_anual).setOnClickListener(null); } else if (bp.isSubscribed(finder.getText(OPC.ID_SUBSCRIPTION_ANNUAL))) { json = new JSONObject(bp.getSubscriptionTransactionDetails( finder.getText(OPC.ID_SUBSCRIPTION_ANNUAL)).purchaseInfo.responseData); calendario.setTime(new Date(json.getLong("purchaseTime"))); calendario.add(Calendar.MONTH, 1); if (calendario.compareTo(Calendar.getInstance()) >= 0) { txtRegalaronSecurify .setText(String.format(finder.getText(OPC.TXT_SUSCRIPCION_CADUCAR), formato.format(calendario.getTime()))); } } else if (bp.isSubscribed(finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL))) { json = new JSONObject(bp.getSubscriptionTransactionDetails( finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL)).purchaseInfo.responseData); txtRegalaronSecurify.setText(bp.getSubscriptionTransactionDetails( finder.getText(OPC.ID_SUBSCRIPTION_MENSUAL)).purchaseInfo.responseData); } else if (bp.isSubscribed(finder.getText(OPC.ID_SUBSCRIPTION_TRAVELER))) { json = new JSONObject(bp.getSubscriptionTransactionDetails(finder .getText(OPC.ID_SUBSCRIPTION_TRAVELER)).purchaseInfo.responseData); txtRegalaronSecurify.setText(bp.getSubscriptionTransactionDetails(finder .getText(OPC.ID_SUBSCRIPTION_TRAVELER)).purchaseInfo.responseData); } } catch (JSONException e) { } } }, getActivity()); } catch (JSONException e) { } } }, getActivity()); txtRegalaronSecurify.setVisibility(View.VISIBLE); return view; }
From source file:interfaces.InterfazPrincipal.java
private void botonGenerarReporteClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGenerarReporteClienteActionPerformed // TODO add your handling code here: try {/*from w ww . j ava 2 s . c o m*/ if (clienteReporteClienteFechaFinal.getSelectedDate().getTime() .compareTo(clienteReporteClienteFechaInicial.getSelectedDate().getTime()) < 0) { JOptionPane.showMessageDialog(this, "La fecha final debe ser posterior al dia de inicio"); } else { final ArrayList<Integer> listaIDFlujos = new ArrayList<>(); final JDialog dialogoEditar = new JDialog(); dialogoEditar.setTitle("Reporte cliente"); dialogoEditar.setSize(350, 610); dialogoEditar.setResizable(false); JPanel panelDialogo = new JPanel(); panelDialogo.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); //c.fill = GridBagConstraints.HORIZONTAL; JLabel ediitarTextoPrincipalDialogo = new JLabel("Informe cliente"); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.insets = new Insets(10, 45, 10, 10); Font textoGrande = new Font("Arial", 1, 18); ediitarTextoPrincipalDialogo.setFont(textoGrande); panelDialogo.add(ediitarTextoPrincipalDialogo, c); final JTable tablaDialogo = new JTable(); DefaultTableModel modeloTabla = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //all cells false return false; } }; ; modeloTabla.addColumn("Factura"); modeloTabla.addColumn("Tipo Flujo"); modeloTabla.addColumn("Fecha"); modeloTabla.addColumn("Valor"); //Llenar tabla ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura(); ArrayList<String[]> flujosCliente = controladorFlujoFactura.getTodosFlujo_Factura( " where factura_id in (select factura_id from Factura where cliente_id = " + String.valueOf(jTextFieldIdentificacionClienteReporte.getText()) + ") order by factura_id"); // {"flujo_id","factura_id","tipo_flujo","fecha","valor"}; ArrayList<Calendar> fechasFlujos = new ArrayList<>(); for (int i = 0; i < flujosCliente.size(); i++) { String fila[] = new String[4]; String[] objeto = flujosCliente.get(i); fila[0] = objeto[1]; fila[1] = objeto[2]; fila[2] = objeto[3]; fila[3] = objeto[4]; //Filtrar, mirar las fechas String[] partirEspacios = objeto[3].split("\\s"); //El primer string es la fecha sin hora //Ahora esparamos por - String[] tomarAgeMesDia = partirEspacios[0].split("-"); //Realizar filtro int ageConsulta = Integer.parseInt(tomarAgeMesDia[0]); int mesConsulta = Integer.parseInt(tomarAgeMesDia[1]); int diaConsulta = Integer.parseInt(tomarAgeMesDia[2]); //Obtenemos dias, mes y ao de la consulta //Inicial int anioInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.YEAR); int mesInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.MONTH) + 1; int diaInicial = clienteReporteClienteFechaFinal.getSelectedDate().get(Calendar.DAY_OF_MONTH); //Final int anioFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.YEAR); int mesFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.MONTH) + 1; int diaFinal = clienteReporteClienteFechaInicial.getSelectedDate().get(Calendar.DAY_OF_MONTH); //Construir fechas Calendar fechaDeLaBD = new GregorianCalendar(ageConsulta, mesConsulta, diaConsulta); //Set year, month, day) Calendar fechaInicialRango = new GregorianCalendar(anioInicial, mesInicial, diaInicial); Calendar fechaFinalRango = new GregorianCalendar(anioFinal, mesFinal, diaFinal); if (fechaDeLaBD.compareTo(fechaInicialRango) <= 0 && fechaDeLaBD.compareTo(fechaFinalRango) >= 0) { fechasFlujos.add(fechaDeLaBD); modeloTabla.addRow(fila); } } if (modeloTabla.getRowCount() > 0) { tablaDialogo.setModel(modeloTabla); tablaDialogo.getColumn("Factura").setMinWidth(80); tablaDialogo.getColumn("Tipo Flujo").setMinWidth(80); tablaDialogo.getColumn("Fecha").setMinWidth(90); tablaDialogo.getColumn("Valor").setMinWidth(80); tablaDialogo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroll = new JScrollPane(tablaDialogo); scroll.setPreferredSize(new Dimension(330, 150)); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.insets = new Insets(0, 0, 0, 0); panelDialogo.add(scroll, c); TimeSeries localTimeSeries = new TimeSeries("Compras del cliente en el periodo"); Map listaAbonos = new HashMap(); for (int i = 0; i < modeloTabla.getRowCount(); i++) { listaIDFlujos.add(Integer.parseInt(flujosCliente.get(i)[0])); if (modeloTabla.getValueAt(i, 1).equals("abono")) { Calendar fechaFlujo = fechasFlujos.get(i); double valor = Double.parseDouble(String.valueOf(modeloTabla.getValueAt(i, 3))); int anoDato = fechaFlujo.get(Calendar.YEAR); int mesDato = fechaFlujo.get(Calendar.MONTH) + 1; int diaDato = fechaFlujo.get(Calendar.DAY_OF_MONTH); Day FechaDato = new Day(diaDato, mesDato, anoDato); if (listaAbonos.get(FechaDato) != null) { double valorAbono = (double) listaAbonos.get(FechaDato); listaAbonos.remove(FechaDato); listaAbonos.put(FechaDato, valorAbono + valor); } else { listaAbonos.put(FechaDato, valor); } } } Double maximo = 0.0; Iterator iterator = listaAbonos.keySet().iterator(); while (iterator.hasNext()) { Day key = (Day) iterator.next(); Double value = (double) listaAbonos.get(key); maximo = Math.max(maximo, value); localTimeSeries.add(key, value); } //localTimeSeries.add(); TimeSeriesCollection datos = new TimeSeriesCollection(localTimeSeries); JFreeChart chart = ChartFactory.createTimeSeriesChart("Compras del cliente en el periodo", // Title "Tiempo", // x-axis Label "Total ($)", // y-axis Label datos, // Dataset true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); /*Altering the graph */ XYPlot plot = (XYPlot) chart.getPlot(); plot.setAxisOffset(new RectangleInsets(5.0, 10.0, 10.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); numberAxis.setRange(new Range(0, maximo * 1.2)); Font font = new Font("Dialog", Font.PLAIN, 9); numberAxis.setTickLabelFont(font); numberAxis.setLabelFont(font); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy")); axis.setAutoTickUnitSelection(false); axis.setVerticalTickLabels(true); axis.setTickLabelFont(font); axis.setLabelFont(font); LegendTitle leyendaChart = chart.getLegend(); leyendaChart.setItemFont(font); Font fontTitulo = new Font("Dialog", Font.BOLD, 12); TextTitle tituloChart = chart.getTitle(); tituloChart.setFont(fontTitulo); ChartPanel CP = new ChartPanel(chart); Dimension D = new Dimension(330, 300); CP.setPreferredSize(D); CP.setVisible(true); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; c.insets = new Insets(10, 0, 0, 0); panelDialogo.add(CP, c); c.gridx = 0; c.gridy = 3; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(10, 30, 0, 0); JButton botonCerrar = new JButton("Cerrar"); botonCerrar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialogoEditar.dispose(); } }); panelDialogo.add(botonCerrar, c); JButton botonGenerarPDF = new JButton("Guardar archivo"); botonGenerarPDF.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente(); reporteFlujosCliente.guardarDocumentoDialogo(dialogoEditar, listaIDFlujos, Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()), clienteReporteClienteFechaInicial.getSelectedDate(), clienteReporteClienteFechaFinal.getSelectedDate()); } }); c.insets = new Insets(10, 100, 0, 0); panelDialogo.add(botonGenerarPDF, c); JButton botonImprimir = new JButton("Imprimir"); botonImprimir.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporteFlujosCliente reporteFlujosCliente = new ReporteFlujosCliente(); reporteFlujosCliente.imprimirFlujo(listaIDFlujos, Integer.parseInt(jTextFieldIdentificacionClienteReporte.getText()), clienteReporteClienteFechaInicial.getSelectedDate(), clienteReporteClienteFechaFinal.getSelectedDate()); } }); c.insets = new Insets(10, 230, 0, 0); panelDialogo.add(botonImprimir, c); dialogoEditar.add(panelDialogo); dialogoEditar.setVisible(true); } else { JOptionPane.showMessageDialog(this, "El cliente no registra movimientos en el rango de fechas seleccionado"); } } } catch (Exception e) { JOptionPane.showMessageDialog(this, "Debe seleccionar un da inicial y final de fechas"); } }
From source file:interfaces.InterfazPrincipal.java
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed ControladorFlujoFactura controladorFlujoFactura = new ControladorFlujoFactura(); ArrayList<String[]> listado = controladorFlujoFactura.getTodosFlujo_Factura(""); DefaultTableModel modelo = (DefaultTableModel) TablaDeReporteDiario.getModel(); if (modelo.getRowCount() > 0) { for (int k = modelo.getRowCount() - 1; k > -1; k--) { modelo.removeRow(k);/*from w w w . ja va2s . co m*/ } } int contador = 1; double abono = 0; double deuda = 0; for (int i = 0; i < listado.size(); i++) { String[] fila = listado.get(i); String[] partirEspacios = fila[3].split("\\s"); //El primer string es la fecha sin hora //Ahora esparamos por - String[] tomarAgeMesDia = partirEspacios[0].split("-"); //Realizar filtro int ageConsulta = Integer.parseInt(tomarAgeMesDia[0]); int mesConsulta = Integer.parseInt(tomarAgeMesDia[1]); int diaConsulta = Integer.parseInt(tomarAgeMesDia[2]); Calendar fechaDeLaBD = new GregorianCalendar(ageConsulta, mesConsulta, diaConsulta); int anioInicial = fechaReporteDiario.getSelectedDate().get(Calendar.YEAR); int mesInicial = fechaReporteDiario.getSelectedDate().get(Calendar.MONTH) + 1; int diaInicial = fechaReporteDiario.getSelectedDate().get(Calendar.DAY_OF_MONTH); Calendar fechaInicialRango = new GregorianCalendar(anioInicial, mesInicial, diaInicial); //fechaReporteDiarioHasta int anioFinal = fechaReporteDiarioHasta.getSelectedDate().get(Calendar.YEAR); int mesFinal = fechaReporteDiarioHasta.getSelectedDate().get(Calendar.MONTH) + 1; int diaFinal = fechaReporteDiarioHasta.getSelectedDate().get(Calendar.DAY_OF_MONTH); Calendar fechaFinalRango = new GregorianCalendar(anioFinal, mesFinal, diaFinal); //System.out.println("antes"); //System.out.println("Va a comparar" + fechaDeLaBD.toString()); //System.out.println(" con " + fechaInicialRango.toString()); if (fechaDeLaBD.compareTo(fechaInicialRango) >= 0 && fechaDeLaBD.compareTo(fechaFinalRango) <= 0) { //System.out.println("Entra"); Object[] row = new Object[5]; row[0] = (contador); contador++; row[1] = fila[1]; row[2] = fila[3]; row[3] = fila[2]; row[4] = fila[4]; modelo.addRow(row); //flujo_id","factura_id","tipo_flujo","fecha","valor" /*System.out.println("fila 0" + fila[0]); System.out.println("fila 1" + fila[1]); System.out.println("fila 2" + fila[2]); System.out.println("fila 3" + fila[3]);*/ if (fila[2].equals("abono")) { abono += Double.parseDouble(fila[4]); } else { deuda += Double.parseDouble(fila[4]); } ; } } ReporteDiarioAbono.setText(abono + ""); ReporteDiarioDeuda.setText(deuda + ""); TablaDeReporteDiario.setModel(modelo); Object opciones[] = { "Cerrar", "Imprimir", "Guardar en disco" }; int opcion = JOptionPane.showOptionDialog(this, "Se ha generado el diario solicitado\nQue desea hacer?", "Elija una opcin", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, opciones, null); GenerarReporteDiario generarReporteDiario = new GenerarReporteDiario(); switch (opcion) { case 1: generarReporteDiario.imprimiDiario(fechaReporteDiario.getSelectedDate(), fechaReporteDiarioHasta.getSelectedDate(), modelo, this); break; case 2: PDDocument documento = generarReporteDiario.crearDiario(fechaReporteDiario.getSelectedDate(), fechaReporteDiarioHasta.getSelectedDate(), modelo, this); JFileChooser fc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivo PDF", "pdf", "text"); fc.setFileFilter(filter); fc.showSaveDialog(this); if (fc.getSelectedFile() != null) { File selectedFile = fc.getSelectedFile(); try { documento.save(selectedFile + ".pdf"); JOptionPane.showMessageDialog(this, "El archivo ha sido guardado en disco"); } catch (Exception ex) { JOptionPane.showMessageDialog(this, "EL Archivo no se puede leer!"); } } break; default: break; } }
From source file:com.l2jfree.gameserver.gameobjects.L2Player.java
private final int getDaysUntilAnniversary() { Calendar now = Calendar.getInstance(); Calendar birth = getCreationDate(); int day = birth.get(Calendar.DAY_OF_MONTH); if (isBirthdayIllegal()) day = 28;//from w w w . jav a 2 s. c o m if (birth.get(Calendar.MONTH) == now.get(Calendar.MONTH) && day == now.get(Calendar.DAY_OF_MONTH)) { if (now.get(Calendar.YEAR) > _lastClaim) return 0; else return 365; } Calendar anno = Calendar.getInstance(); anno.setTimeInMillis(birth.getTimeInMillis()); anno.set(Calendar.DAY_OF_MONTH, day); anno.set(Calendar.YEAR, now.get(Calendar.YEAR)); if (anno.compareTo(now) < 0) anno.add(Calendar.YEAR, 1); long diff = (anno.getTimeInMillis() - now.getTimeInMillis()); return (int) (diff / 86400000) + 1; }
From source file:com.clark.func.Functions.java
/** * Determines how two calendars compare up to no more than the specified * most significant field.//from ww w . j ava2 s. c o m * * @param cal1 * the first calendar, not <code>null</code> * @param cal2 * the second calendar, not <code>null</code> * @param field * the field from <code>Calendar</code> * @return a negative integer, zero, or a positive integer as the first * calendar is less than, equal to, or greater than the second. * @throws IllegalArgumentException * if any argument is <code>null</code> * @see #truncateCalendar(Calendar, int) * @see #truncatedCompareTo(Date, Date, int) * @since 3.0 */ public static int truncatedCompareTo(Calendar cal1, Calendar cal2, int field) { Calendar truncatedCal1 = truncateCalendar(cal1, field); Calendar truncatedCal2 = truncateCalendar(cal2, field); return truncatedCal1.compareTo(truncatedCal2); }