List of usage examples for org.joda.time DateTime DateTime
public DateTime(Object instant)
From source file:access.deploy.Leaser.java
License:Apache License
/** * Renews the existing Deployment. This Deployment must exist in the Deployments collection. * //from w w w.j av a 2s.c om * @param deployment * The deployment to renew. * @param durationDays * The number of days to renew the lease by. * @return The Lease for this Deployment */ public Lease renewDeploymentLease(Deployment deployment, Integer durationDays) { Lease lease = accessor.getDeploymentLease(deployment); // If the lease has been reaped by the database, then create a new // Lease. if (lease == null) { lease = createDeploymentLease(deployment, durationDays); } else { DateTime expirationDate = new DateTime(lease.getExpiresOn()); if (expirationDate.isBeforeNow()) { // If the Lease has expired, then the Lease will be extended for // the default Lease period. Integer updatedDurationDays = ((durationDays != null) && (durationDays.intValue() > 0)) ? durationDays : DEFAULT_LEASE_PERIOD_DAYS; accessor.updateLeaseExpirationDate(lease.getLeaseId(), DateTime.now().plusDays(updatedDurationDays.intValue()).toString()); pzLogger.log( String.format("Updating Deployment Lease for Deployment %s on host %s for %s", deployment.getDeploymentId(), deployment.getHost(), deployment.getDataId()), Severity.INFORMATIONAL, new AuditElement(ACCESS, "renewDeploymentLease", deployment.getDeploymentId())); } else { // If the Lease has not expired, then the Lease will not be // extended. It will simply be reused. } } return lease; }
From source file:account.logic.AccountController.java
@FXML public void paymentDays(String username) throws ParseException, SQLException { this.username = username; Boolean b = false;/*from www . j a v a2 s . c om*/ String paymentDate = ""; Database db = new Database(); b = db.checkSub(username); if (b) { int daysLeft = 0; SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); Date date = new Date(); Date d1 = null; Date d2 = null; int customerID = db.getCustomerID(username); String dlp = db.getLastPayment(customerID); String de = format.format(date); try { d1 = format.parse(dlp); d2 = format.parse(de); DateTime dt1 = new DateTime(d1); DateTime dt2 = new DateTime(d2); Calendar day = Calendar.getInstance(); int days = day.getActualMaximum(Calendar.DAY_OF_MONTH); int daysBetween = Days.daysBetween(dt1, dt2).getDays(); daysLeft = days - daysBetween; payment.setText(Integer.toString(daysLeft) + " days"); lastPayment.setText(dlp); } catch (Exception e) { e.printStackTrace(); } if (daysLeft != 0) { pay.setDisable(true); } else if (daysLeft < 0) { db.deleteSubRecord(customerID); db.paymentMissed(customerID); } } else { paymentlabel.setVisible(false); payDue.setVisible(false); subscribelabel.setVisible(true); todaylabel.setVisible(true); lplabel.setVisible(false); pay.setVisible(false); payment.setVisible(false); lastPayment.setVisible(false); changesub.setVisible(true); } }
From source file:account.logic.AccountController.java
public boolean checkDeviceDate(int deviceID) { Boolean isOneMonth = false;/*from w w w . j a v a 2 s.c om*/ Database db = new Database(); String id = db.dateDeviceAdded(deviceID); SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); Date date = new Date(); Date d1 = null; Date d2 = null; String da = id; String de = format.format(date); try { d1 = format.parse(da); d2 = format.parse(de); DateTime dt1 = new DateTime(d1); DateTime dt2 = new DateTime(d1); int daysBetween = Days.daysBetween(dt1, dt2).getDays(); System.out.println(daysBetween + "daysbetween"); if (daysBetween > 30) { isOneMonth = true; } } catch (Exception e) { e.printStackTrace(); } return isOneMonth; }
From source file:aDeleteME.DeleteME.java
public static void main(String[] args) { Random random = new Random(); DateTime startTime = new DateTime(random.nextLong()).withMillisOfSecond(0); Minutes minimumPeriod = Minutes.TWO; int minimumPeriodInSeconds = minimumPeriod.toStandardSeconds().getSeconds(); int maximumPeriodInSeconds = Hours.ONE.toStandardSeconds().getSeconds(); Seconds randomPeriod = Seconds.seconds(random.nextInt(maximumPeriodInSeconds - minimumPeriodInSeconds)); DateTime endTime = startTime.plus(minimumPeriod).plus(randomPeriod); DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); System.out.println(dateTimeFormatter.print(startTime)); System.out.println(dateTimeFormatter.print(endTime)); }
From source file:annis.gui.admin.converter.DateTimeConverter.java
License:Apache License
@Override public DateTime convertToModel(Date value, Class<? extends DateTime> targetType, Locale locale) throws ConversionException { if (value == null) { return null; }/*www . j av a2s . co m*/ return new DateTime(value); }
From source file:aplicacion.control.AsignarHorasExtrasController.java
public void createArrayControles(Integer diasDelRango) { int cantidad = diasDelRango; ArrayList<ControlExtras> controlesCrear = new ArrayList<>(); // control diarios que salen de turnosTableView (no tienen fecha) for (ControlExtras ce : dataTurnos) { Integer dias = Integer.valueOf(ce.getDias()); while (dias > 0) { controlesCrear.add(ce.clone()); dias--;/*w w w. jav a2 s .com*/ } } DateTime fecha = new DateTime(inicio.getTime()); rangoControls = new ArrayList<>(); int count = 0; while (cantidad > 0) { // se agregan los controles limitados por el rango de fecha for (ControlExtras ce : controlesCrear) { // y se le agrega la fecha correspondiente ControlExtras control = ce.clone(); control.setFecha(new Date(fecha.plusDays(count).getMillis())); rangoControls.add(control); cantidad--; count++; if (cantidad == 0) { break; } } } }
From source file:aplicacion.control.AsignarHorasExtrasController.java
void addDaysColumns(int count) { DateTime fecha = new DateTime(inicio.getTime()); fecha = fecha.plusDays(count);//from w w w . j ava2 s. c o m String day = fecha.toCalendar(Locale.getDefault()).getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()); TableColumn columna = new TableColumn(day + " " + fecha.getDayOfMonth() + "/" + fecha.getMonthOfYear()); columna.setPrefWidth(120); columna.setStyle("-fx-alignment: center;"); columna.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<EmpleadoTable, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(TableColumn.CellDataFeatures<EmpleadoTable, String> data) { if (data.getValue().getExtras() == null) return null; return new ReadOnlyStringWrapper(getTextHorario(data.getValue().getExtras().get(count))); } }); empleadosTableView.getColumns().add(columna); }
From source file:aplicacion.control.EmpleadoController.java
public void setEmpleado(Usuario empleado) throws IOException, SQLException { this.empleado = empleado; nombre.setText(empleado.getNombre() + " " + empleado.getApellido()); cedula.setText(empleado.getCedula()); telefono.setText(empleado.getTelefono()); direccion.setText(empleado.getDireccion()); email.setText(empleado.getEmail());//from www . java2s . c o m estadoCivil.setText(empleado.getEstadoCivil().getNombre()); empresa.setText(empleado.getDetallesEmpleado().getEmpresa().getNombre()); departamento.setText(empleado.getDetallesEmpleado().getDepartamento().getNombre()); cargo.setText(empleado.getDetallesEmpleado().getCargo().getNombre()); cuenta.setText(empleado.getDetallesEmpleado().getNroCuenta()); sueldo.setText("$" + empleado.getDetallesEmpleado().getSueldo()); extra.setText(empleado.getDetallesEmpleado().getExtra()); DateTime inicio = new DateTime(empleado.getDetallesEmpleado().getFechaInicio().getTime()); fechaInicio.setText( inicio.getDayOfMonth() + " de " + getMonthName(inicio.getMonthOfYear()) + " " + inicio.getYear()); DateTime contrato = new DateTime(empleado.getDetallesEmpleado().getFechaContrato().getTime()); fechaContrato.setText(contrato.getDayOfMonth() + " de " + getMonthName(contrato.getMonthOfYear()) + " " + contrato.getYear()); DateTime nacimiento = new DateTime(empleado.getNacimiento().getTime()); cumpleano.setText(nacimiento.getDayOfMonth() + " de " + getMonthName(nacimiento.getMonthOfYear()) + " " + nacimiento.getYear()); Foto foto = new FotoDAO().findByEmpleadoId(empleado.getId()); if (foto != null && foto.getFoto() != null) { final BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(foto.getFoto())); Image image = SwingFXUtils.toFXImage(bufferedImage, null); setProfileImage(image); } }
From source file:aplicacion.control.HorarioEmpleadoController.java
public void buscarRoles(Timestamp fecha, int dias) { DateTime tiempo = new DateTime(fecha.getTime()); if (dias > 1) { int comienzoMes = empresa.getComienzoMes(); tiempo.plusDays(1);/*from w w w. j a va 2 s . co m*/ } }
From source file:aplicacion.control.HorarioEmpleadoController.java
public static LocalDate getDateFromTimestamp(Timestamp timestamp) { if (timestamp == null) { return null; } else {//from w ww .j a v a 2 s . com DateTime dateTime = new DateTime(timestamp.getTime()); return LocalDate.of(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth()); } }