List of usage examples for java.sql Date valueOf
@SuppressWarnings("deprecation") public static Date valueOf(LocalDate date)
From source file:org.crm.web.services.create.CreateOrderPot.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w w w . j a v a2s .com*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { /* CREATE TABLE `orderPot` ( id INT(11) NOT NULL AUTO_INCREMENT, productId INT(11) NOT NULL DEFAULT 0, quantity INT(11) NOT NULL DEFAULT 0, price FLOAT(11) NOT NULL DEFAULT 0,/*service : MALIYET(Ana Balk) createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 CHARSET=utf8; */ String productIdParam = request.getParameter("productId"); String quantityParam = request.getParameter("quantity"); String priceParam = request.getParameter("price");//TODO : Hesaplanacak String clientOrganizationAddressIdParam = request.getParameter("clAdrId"); String deliveryAtParam = request.getParameter("deliveryAt"); String orderTypeIdParam = request.getParameter("orderyTypeId"); String productionTypeIdParam = request.getParameter("productionTypeId"); if ((productIdParam == null) || (quantityParam == null) || (priceParam == null) || (clientOrganizationAddressIdParam == null) || (deliveryAtParam == null) || (orderTypeIdParam == null) || (productIdParam == null)) { return;//TODO : hata kodu baslacak } if (productIdParam.equals("") || quantityParam.equals("") || priceParam.equals("") || clientOrganizationAddressIdParam.equals("") || (deliveryAtParam.equals("")) || orderTypeIdParam.equals("") || productIdParam.equals("")) { return;//TODO : hata kodu baslacak } Integer productId = Integer.parseInt(productIdParam); Integer quantity = Integer.parseInt(quantityParam); Double price = Double.parseDouble(priceParam); Integer clientOrganizationAddressId = Integer.parseInt(clientOrganizationAddressIdParam); Date deliveryAt = Date.valueOf(deliveryAtParam); Integer orderTypeId = Integer.parseInt(orderTypeIdParam); Integer productionTypeId = Integer.parseInt(productionTypeIdParam); if ((productId == null) || (quantity == null) || (price == null) || (clientOrganizationAddressId == null) || (deliveryAt == null) || (orderTypeId == null)) { return;//TODO : hata kodu } OrderPot orderPot = new OrderPot(); orderPot.setProductId(productId); orderPot.setQuantity(quantity); orderPot.setPrice(price); orderPot.setClientOrganizationAddressId(clientOrganizationAddressId); orderPot.setDeliveryAt(deliveryAt); orderPot.setOrderTypeId(orderTypeId); orderPot.setProductionTypeId(productionTypeId); orderPot.setIsComplete(OrderPotCompleteStatus.NOT_COMPLETED.getKey()); OrderPotDBManager orderPotDBManager = new OrderPotDBManager(); orderPot = orderPotDBManager.saveOrderPot(orderPot); JSONObject jsonResult = new JSONObject(); jsonResult.put("id", orderPot.getId()); out.println(jsonResult); } finally { out.close(); } }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.AuthorManagerImpl.java
@Override @Transactional(readOnly = false)//from w ww . j a v a2 s.co m public void createAuthor(Author author) { validate(author); if (author.getId() != null) { throw new IllegalArgumentException("author id is already set"); } KeyHolder keyHolder = new GeneratedKeyHolder(); int updated = jdbcTemplate.update((Connection connection) -> { PreparedStatement ps = connection.prepareStatement( "INSERT INTO AUTHOR (firstname,surname,description,nationality,dateofbirth) VALUES (?,?,?,?,?)", Statement.RETURN_GENERATED_KEYS); ps.setString(1, author.getFirstname()); ps.setString(2, author.getSurname()); ps.setString(3, author.getDescription()); ps.setString(4, author.getNationality()); Date date = Date.valueOf(author.getDateOfBirth()); ps.setDate(5, date); return ps; }, keyHolder); author.setId(keyHolder.getKey().longValue()); DBUtils.checkUpdatesCount(updated, author, true); }
From source file:me.redstarstar.rdfx.duty.dao.jdbc.ScheduleJdbcDao.java
@Override public void save(Schedule schedule) { jdbcTemplate.execute("INSERT INTO schedule (parent_id, week, activity_date, create_date, update_date) " + "VALUES (?, ?, ?, NOW(), NOW());", (PreparedStatement preparedStatement) -> { preparedStatement.setLong(1, schedule.getParentId()); preparedStatement.setInt(2, schedule.getWeek()); preparedStatement.setDate(3, Date.valueOf(schedule.getActivityDate())); preparedStatement.execute(); return null; });//from w ww. ja v a 2 s . c o m }
From source file:agendapoo.View.FrmMinhaAtividade.java
private void loadDate() { //pick an istance of Calendar w/ the current System Time Calendar calendar = Calendar.getInstance(); //picks an instance of Date w/ my SelectedAtividade's LocalDate value. Date d = Date.valueOf(selectedAtividade.getData()); //Setting the Calendar time to my Date calendar.setTime(d);/*from ww w . j av a 2 s .co m*/ //Instanciate a new PeriodSet PeriodSet p = new PeriodSet(); //Added my calendar w/ my new Date to my PeriodSet p.add(calendar); //finally setDefaultPeriods to my new PeriodSet time wich throws a RuntimeException try { textData.setDefaultPeriods(p); } catch (IncompatibleDataExeption ide) { JOptionPane.showMessageDialog(this, ide.getMessage()); } }
From source file:com.ar.hotwiredautorepairshop.controller.ServiceOrderController.java
@RequestMapping(value = "/serviceOrders/register/new", method = RequestMethod.POST) public ServiceOrder registerServiceOrder(@RequestParam(value = "customerSSN") String customerSSN, @RequestParam(value = "licensePlate") String licensePlate, @RequestParam(value = "mechanicSSN") String mechanicSSN, @RequestParam(value = "serviceDate") String serviceDate, @RequestParam(value = "pickupDate") String pickupDate, @RequestParam(value = "workTypeIds") List<String> workTypeIds, @RequestParam(value = "complaintId") Integer complaintId) { ServiceOrder newServiceOrder = new ServiceOrder(); java.util.Date utilDate = new java.util.Date(); Date registrationDate = new Date(utilDate.getTime()); newServiceOrder.setRegistrationDate(registrationDate); Customer customer = customerRepository.findOne(customerSSN); Mechanic mechanic = mechanicRepository.findOne(mechanicSSN); Car car = carRepository.findOne(licensePlate); if (!mechanic.getCarsInProgress().contains(car)) { mechanic.getCarsInProgress().add(car); }//from w ww . j a va 2 s. c o m if (complaintId != null) { newServiceOrder.setComplaint(complaintRepository.findOne(complaintId)); } newServiceOrder.setCustomer(customer); newServiceOrder.setCar(car); newServiceOrder.setMechanic(mechanic); newServiceOrder.setServiceDate(Date.valueOf(serviceDate)); newServiceOrder.setPickupDate(Date.valueOf(pickupDate)); int totalPrice = 0; for (String workTypeId : workTypeIds) { WorkType workType = workTypeRepository.findOne(Integer.parseInt(workTypeId)); newServiceOrder.getWorkTypes().add(workType); totalPrice += workType.getPrice(); } newServiceOrder.setTotalPrice(totalPrice); newServiceOrder.setActive(true); serviceOrderRepository.save(newServiceOrder); return newServiceOrder; }
From source file:GUIpresentacion.GUINuevaPlanillaIncripcion.java
private void cargo_datos() throws ParseException { //SimpleDateFormat formatoDelTexto = new SimpleDateFormat(yyyy-MM-dd'); fechaactual = Calendar.getInstance(); //nacimientoChooser.getSelectedDate(); if (Utilidad.areEqualDays(fechaactual, nacimientoChooser.getSelectedDate())) { System.out.println(">> " + Utilidad.convertToSqlDate(nacimientoChooser.getSelectedDate())); }/*from w ww.ja v a 2s .co m*/ if (!dni_cuit_texto.getText().isEmpty()) abogado.setDNI(Integer.parseInt(dni_cuit_texto.getText())); if (!inicio_cuit_texto.getText().isEmpty() && !dni_cuit_texto.getText().isEmpty() && !fin_cuit_texto.getText().isEmpty()) abogado.set_cuit(Long .valueOf(inicio_cuit_texto.getText() + dni_cuit_texto.getText() + fin_cuit_texto.getText())); if (Utilidad.getAnio(Date.valueOf(convertToSqlDate(fechaactual))) < Utilidad .getAnio(Date.valueOf(convertToSqlDate(nacimientoChooser.getSelectedDate())))) abogado.set_fechanac( Utilidad.DeStringADate(Utilidad.convertToSqlDate(nacimientoChooser.getSelectedDate()))); if (!apellidoTexto.getText().isEmpty()) abogado.set_apellido(apellidoTexto.getText()); if (!nobreTexto.getText().isEmpty()) abogado.set_nombre(nobreTexto.getText()); if (estadoCivilBox != null) abogado.setEstadoCivil(estadoCivilBox.getSelectedItem().toString()); if (universidadBox != null) universidad.set_nombre(universidadBox.getSelectedItem().toString()); if (fechaexpChooser != null) abogado.set_fecha_titulo( Utilidad.DeStringADate(Utilidad.convertToSqlDate(fechaexpChooser.getSelectedDate()))); if (!calleRTexto.getText().isEmpty()) abogado.set_dR_Calle(calleRTexto.getText()); if (!nroRTexto.getText().isEmpty()) abogado.set_dR_Nro(Integer.parseInt(nroRTexto.getText())); if (localidadRBox != null) abogado.set_dR_Localidad(localidadRBox.getSelectedItem().toString()); if (provinciaRBox != null) abogado.set_dR_Provincia(provinciaRBox.getSelectedItem().toString()); if (!telRTexto.getText().isEmpty()) abogado.set_telefono_particualr(Integer.parseInt(telRTexto.getText())); if (!calleRTexto.getText().isEmpty()) abogado.set_dP_calle(calleRTexto.getText()); if (!nroPTexto.getText().isEmpty()) abogado.set_dP_nro(Integer.parseInt(nroPTexto.getText())); if (localidadPBox != null) abogado.set_dP_localidad(localidadPBox.getSelectedItem().toString()); if (provinciaPBox != null) abogado.set_dP_provincia(provinciaPBox.getSelectedItem().toString()); if (!telPTexto.getText().isEmpty()) abogado.set_tel_profecional(Integer.parseInt(telPTexto.getText())); if (!emailTexto.getText().isEmpty()) abogado.set_email(emailTexto.getText()); if (!nombreFamiliaTexto.getText().isEmpty()) familiar.set_nombre(nombreFamiliaTexto.getText()); //abogado.getFamilar().set_nombre(apellidoFamiliaTexto.getText()); if (!apellidoFamiliaTexto.getText().isEmpty()) { familiar.set_apellido(apellidoFamiliaTexto.getText()); familiar.setTipo_familiar(tipoFamiliarBox.getSelectedItem().toString()); } if (regimenBox != null) abogado.setRegimen(regimenBox.getSelectedItem().toString()); if (Utilidad.getAnio(Date.valueOf(convertToSqlDate(fechaactual))) < Utilidad .getAnio(Date.valueOf(convertToSqlDate(fechaRegimenInicioChooser.getSelectedDate())))) abogado.setRegimen_inicio( Utilidad.DeStringADate(Utilidad.convertToSqlDate(fechaRegimenInicioChooser.getSelectedDate()))); if (Utilidad.getAnio(Date.valueOf(convertToSqlDate(fechaactual))) < Utilidad .getAnio(Date.valueOf(convertToSqlDate(fechaRegimenFinalChooser.getSelectedDate())))) abogado.setRegimen_final( Utilidad.DeStringADate(Utilidad.convertToSqlDate(fechaRegimenFinalChooser.getSelectedDate()))); if (obraSocialBox != null) abogado.setObraSocial(obraSocialBox.getSelectedItem().toString()); abogado.setFamilar(familiar); }
From source file:org.kuali.kra.committee.service.CommitteeBatchCorrespondenceServiceTest.java
/** * This method tests the creation of batch correspondence * @throws Exception/*w w w . j av a 2s . c o m*/ */ @Test public void testGenerateBatchCorrespondenceForRenewalReminders() throws Exception { String batchCorrespondenceTypeCode = Constants.PROTOCOL_RENEWAL_REMINDERS; Committee committee = ((List<Committee>) KNSServiceLocator.getBusinessObjectService() .findAll(Committee.class)).get(0); final String committeeId = committee.getCommitteeId(); final Date startDate = Date.valueOf("2010-06-01"); final Date endDate = Date.valueOf("2010-06-15"); committeeBatchCorrespondenceServiceImpl .setBusinessObjectService(new CommitteeTestHelper.MockBusinessObjectService()); final ProtocolDao protocolDao = context.mock(ProtocolDao.class); final List<Protocol> protocols = initProtocols(); context.checking(new Expectations() { { oneOf(protocolDao).getExpiringProtocols(committeeId, startDate, endDate); will(returnValue(protocols)); } }); committeeBatchCorrespondenceServiceImpl.setProtocolDao(protocolDao); final ProtocolCorrespondenceTemplateService protocolCorrespondenceTemplateService = context .mock(ProtocolCorrespondenceTemplateService.class); context.checking(new Expectations() { { oneOf(protocolCorrespondenceTemplateService) .getProtocolCorrespondenceTemplate(with(any(String.class)), with(any(String.class))); will(returnValue(new ProtocolCorrespondenceTemplate())); } }); committeeBatchCorrespondenceServiceImpl .setProtocolCorrespondenceTemplateService(protocolCorrespondenceTemplateService); CommitteeBatchCorrespondence committeeBatchCorrespondence = (CommitteeBatchCorrespondence) committeeBatchCorrespondenceServiceImpl .generateBatchCorrespondence(batchCorrespondenceTypeCode, committeeId, startDate, endDate); // assert CommitteeBatchCorrespondence assertEquals(committeeId, committeeBatchCorrespondence.getCommitteeId()); assertEquals(batchCorrespondenceTypeCode, committeeBatchCorrespondence.getBatchCorrespondenceTypeCode()); assertEquals(startDate, committeeBatchCorrespondence.getTimeWindowStart()); assertEquals(endDate, committeeBatchCorrespondence.getTimeWindowEnd()); // assert CommitteeBatchCorrespondenceDetail assertEquals(1, committeeBatchCorrespondence.getCommitteeBatchCorrespondenceDetails().size()); assertEquals(committeeBatchCorrespondence.getCommitteeBatchCorrespondenceId(), committeeBatchCorrespondence .getCommitteeBatchCorrespondenceDetails().get(0).getCommitteeBatchCorrespondenceId()); assertEquals("Renewal Reminder Letter #1", committeeBatchCorrespondence .getCommitteeBatchCorrespondenceDetails().get(0).getProtocolAction().getComments()); }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.BookManagerImpl.java
@Override @Transactional(readOnly = false)//from www . j av a 2s . c o m public void updateBook(Book book) { validate(book); if (book.getId() == null) { throw new IllegalArgumentException("book id is null"); } int updated = jdbcTemplate.update( "UPDATE Book SET name = ?, isbn = ?, published = ?, author_id = ? WHERE id = ?", book.getName(), book.getIsbn(), Date.valueOf(book.getPublished()), book.getAuthorId(), book.getId()); DBUtils.checkUpdatesCount(updated, book, false); }
From source file:cz.muni.fi.sport.club.sport.club.rest.AgeGroupsResource.java
@POST @Produces(MediaType.APPLICATION_JSON)//w ww . j a v a 2s . c o m public Response create(@FormParam("eldest") String eldest, @FormParam("youngest") String youngest, @FormParam("groupLevel") String groupLevel) throws WebApplicationException { try { AgeGroupDTO agDTO = ageGroupService.createAgeGroup(Date.valueOf(eldest), Date.valueOf(youngest), AgeGroupLevel.valueOf(groupLevel)); AgeGroup ageGroup = AgeGroupMapping.toEntity(ageGroupService.saveAgeGroup(agDTO)); return Response.created(URI.create(context.getAbsolutePath() + "/" + ageGroup.getId())).build(); } catch (WebApplicationException ex) { throw new WebApplicationException(new Throwable("You post wrong request"), Response.Status.BAD_REQUEST); } catch (Exception ex) { throw new WebApplicationException(new Throwable("We apologize for internal server error"), Response.Status.INTERNAL_SERVER_ERROR); } }
From source file:org.kuali.kfs.sys.fixture.AccountFixture.java
public Date getAccountExpirationDate() { return Date.valueOf(this.accountExpirationDate); }