List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:ch.bfh.srs.srv.service.ReservationServiceTest.java
@Test(expected = NotImplementedException.class) public void testModRecurringReservation() { DateTime from = DateTime.now();/* ww w.j av a 2 s . com*/ DateTime to = DateTime.now().plus(Period.hours(4)); boolean modified = service.modRecurringReservation(1, from, to, false, 1, null, null); assertTrue(modified); Reservation reservationEntity = service.getById(Reservation.class, 1); assertNotNull(reservationEntity); assertEquals(new Timestamp(from.getMillis()), reservationEntity.getFrom()); assertEquals(new Timestamp(to.getMillis()), reservationEntity.getTo()); assertFalse(reservationEntity.getFullDay()); }
From source file:com.suntek.gztpb.controller.ChemicalController.java
@RequestMapping(value = "saveApply.htm", method = RequestMethod.POST) public @ResponseBody String saveApply(ChemicalModel chemcial, HttpServletRequest request, HttpServletResponse response) throws ServiceException, IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/html"); Timestamp now = null;// w ww . j a v a2 s .c o m PrintWriter out = response.getWriter(); try { now = new Timestamp(System.currentTimeMillis()); String applyNum = IdGenerator.getInstance().getBizCode("ITMS_SEQ", 5); chemcial.setApplyNum(applyNum); chemcial.setBizType("0401"); //0401 ???? chemcial.setApplyTime(now); String line = request.getParameter("beginLine") + "" + request.getParameter("finishLine"); chemcial.setLine(line); Timestamp goBeginTime = CommonUtil.parseToTimestamp("yyyy-MM-dd HH:mm:ss", request.getParameter("beginTime").trim()); Timestamp goFinishTime = CommonUtil.parseToTimestamp("yyyy-MM-dd HH:mm:ss", request.getParameter("finishTime").trim()); chemcial.setGoBeginTime(goBeginTime); chemcial.setGoFinishTime(goFinishTime); chemcial.setSource(0);//??0 gztpb;9 ; chemcial.setCreator("admin"); chemcial.setCreatedTime(now); chemcial.setSubmiTime(now); chemcial.setFinish(0); chemicalService.signUp(chemcial); out.write("<script>parent.saveCallback('1','" + applyNum + "');</script>"); } catch (Exception e1) { System.out.println( "[gztpbwebsite]ChemicalController.saveApply,?????" + e1.getMessage()); out.write("<script>parent.saveCallback('0');</script>"); } return null; }
From source file:ru.trett.cis.services.InventoryServiceImpl.java
@Override @Transactional/*from www . j a v a 2 s.c o m*/ public Long save(final Long employeeId, final List<Asset> assetList, String status, String loginName) throws BindingException { Timestamp date = new Timestamp(new Date().getTime()); Employee employee = findById(Employee.class, employeeId); User issuer = userDAO.findByLoginName(loginName); Invoice invoice = new Invoice(date, EnumUtil.lookup(Invoice.Status.class, status), issuer, employee); save(invoice); for (Asset asset : assetList) { DeviceModel deviceModel = getModelByTypeAndBrandAndModel( asset.getDeviceModel().getDeviceType().getType(), asset.getDeviceModel().getDeviceBrand().getBrand(), asset.getDeviceModel().getModel()); if (deviceModel == null) throw new BindingException("Device Model is unknown."); // check if asset exists if (!asset.getSerialNumber().isEmpty()) { List<Asset> assets = assetDAO.getAssetsBySerialNumber(asset.getSerialNumber().toUpperCase()); if (!assets.isEmpty()) { for (Asset a : assets) { if (a.getDeviceModel().equals(deviceModel)) asset = a; } } } asset.setDeviceModel(deviceModel); asset.setSerialNumber(asset.getSerialNumber().toUpperCase()); asset.setInventoryNumber(asset.getInventoryNumber().toUpperCase()); asset.setEmployee(employee); switch (invoice.getStatus()) { case PUBLISHED: asset.setStatus(Asset.Status.ACTIVE); break; case DRAFT: asset.setStatus(Asset.Status.IN_STOCK); break; } save(asset); EmployeeAsset employeeAsset = new EmployeeAsset(employee, asset, invoice); save(employeeAsset); Tracking tracking = new Tracking(issuer, date, asset, "Was created and added to Database"); save(tracking); } return invoice.getId(); }
From source file:it.cnr.icar.eric.server.persistence.rdb.SubscriptionDAO.java
/** * Returns the SQL fragment string needed by insert or update statements * within insert or update method of sub-classes. This is done to avoid code * duplication./*from www. j av a 2 s. c om*/ */ protected String getSQLStatementFragment(Object ro) throws RegistryException { SubscriptionType subscription = (SubscriptionType) ro; String stmtFragment = null; String selector = subscription.getSelector(); XMLGregorianCalendar endTime = subscription.getEndTime(); String endTimeAsString = null; if (endTime != null) { endTimeAsString = " '" + (new Timestamp(endTime.toGregorianCalendar().getTimeInMillis())) + "'"; } Duration notificationInterval = subscription.getNotificationInterval(); String notificationIntervalString = ""; if (notificationInterval != null) { notificationIntervalString = "'" + notificationInterval.toString() + "'"; } // xxx 120203 pa fix for missing XJC/JAXB generated default value for // duration else { notificationIntervalString = "'P1D'"; } XMLGregorianCalendar startTime = subscription.getStartTime(); String startTimeAsString = null; if (startTime != null) { startTimeAsString = " '" + (new Timestamp(startTime.toGregorianCalendar().getTimeInMillis())) + "'"; } if (action == DAO_ACTION_INSERT) { stmtFragment = "INSERT INTO Subscription " + super.getSQLStatementFragment(ro) + ", '" + selector + "', " + endTimeAsString + ", " + notificationIntervalString + ", " + startTimeAsString + " ) "; } else if (action == DAO_ACTION_UPDATE) { stmtFragment = "UPDATE Subscription SET " + super.getSQLStatementFragment(ro) + ", selector='" + selector + "', endTime=" + endTimeAsString + ", notificationInterval=" + notificationIntervalString + ", startTime=" + startTimeAsString + " WHERE id = '" + ((RegistryObjectType) ro).getId() + "' "; } else if (action == DAO_ACTION_DELETE) { stmtFragment = super.getSQLStatementFragment(ro); } return stmtFragment; }
From source file:org.cleverbus.core.common.dao.ExternalCallDaoJpaImpl.java
@Override @Nullable//from w ww . j a va 2 s.co m @SuppressWarnings("unchecked") public ExternalCall findConfirmation(int interval) { // find confirmation that was lastly processed before specified interval Date lastUpdateLimit = DateUtils.addSeconds(new Date(), -interval); String jSql = "SELECT c " + "FROM " + ExternalCall.class.getName() + " c " + "WHERE c.operationName = :operationName" + " AND c.state = :state" + " AND c.lastUpdateTimestamp < :lastUpdateTimestamp" + " ORDER BY c.creationTimestamp"; TypedQuery<ExternalCall> q = em.createQuery(jSql, ExternalCall.class); q.setParameter("operationName", ExternalCall.CONFIRM_OPERATION); q.setParameter("state", ExternalCallStateEnum.FAILED); q.setParameter("lastUpdateTimestamp", new Timestamp(lastUpdateLimit.getTime())); q.setMaxResults(1); List<ExternalCall> extCalls = q.getResultList(); if (extCalls.isEmpty()) { return null; } else { return extCalls.get(0); } }
From source file:com.wizecommerce.hecuba.JSONResultSet.java
@Deprecated public Timestamp getSQLTimeStamp(String fieldName, Timestamp defaultDate) { Long epoch = (Long) decoder.get(fieldName); return (epoch == null) ? defaultDate : new Timestamp(epoch); }
From source file:ManagedBeans.TaskBean.java
public String login() throws IOException { TareaScrum t = new TareaScrum(); FicherosScrum fichero = new FicherosScrum(); TareaScrum editTarea = null;/* w ww .ja v a 2 s. c o m*/ RequestContext context = RequestContext.getCurrentInstance(); FacesMessage message; boolean loggedIn = true; Timestamp insertarTiempo; insertarTiempo = new Timestamp(tiempo.getTime()); t.setNombre(titulo); t.setDescripcion(descripcion); t.setEstado(estadoSeleccionado); t.setIdUsuario(loginBean.user); t.setIdProyecto(loginBean.selectedProject); t.setTiempoEstimado(insertarTiempo); Calendar cal = Calendar.getInstance(); t.setFechaIni(cal.getTime()); if (!file.getFileName().equals("")) { byte[] bytes = IOUtils.toByteArray(file.getInputstream()); fichero.setFichero(bytes); fichero.setExt(file.getFileName()); ficherosScrumFacade.create(fichero); t.setIdFichero(fichero); } tareaScrumFacade.create(t); message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Tarea", "La tarea se ha creado correctamente"); FacesContext.getCurrentInstance().addMessage(null, message); context.addCallbackParam("loggedIn", loggedIn); loginBean.selectedProject.getTareaScrumCollection().add(t); proyectoScrumFacade.edit(loginBean.selectedProject); return "manageProject"; }
From source file:eionet.webq.dao.ProjectFileStorageImpl.java
/** * Updates all fields.//from ww w .ja v a2 s . c om * * @param projectFile project file */ private void fullUpdate(ProjectFile projectFile) { Session currentSession = getCurrentSession(); projectFile.setUpdated(new Timestamp(System.currentTimeMillis())); currentSession.merge(projectFile); currentSession.flush(); }
From source file:com.matrimony.controller.ProfileController.java
@RequestMapping(value = "updateMyMeasurements", method = RequestMethod.POST, produces = "application/json") @ResponseBody//from w ww . j a v a 2 s .co m public String doUpdateMyMeasurements(HttpServletRequest request, User userMeasurement) { User ssUser = (User) request.getSession().getAttribute("user"); Timestamp currentTime = new Timestamp(System.currentTimeMillis()); if (ssUser == null) return null; Properties props = new Properties(); props.put("wellForm", true); ssUser.setHeight(userMeasurement.getHeight()); ssUser.setWeight(userMeasurement.getWeight()); ssUser.setUpdateTime(currentTime); UserDAO.Update(ssUser); String json = Global.gson.toJson(props); return json; }
From source file:com.htm.test.TaskInstanceDummyProvider.java
protected Set<IAttachment> getAttachmentDummies() throws DatabaseException { Set<IAttachment> attachments = new HashSet<IAttachment>(); IAttachment attachment = this.taskInstanceFactory.createAttachment("Attachment1"); /* Add first attachment. It contains a simple String*/ attachment.setAccessType(IAttachment.ACCESS_TYPE_INLINE); attachment.setContentType("Good old String"); attachment.setContent(Utilities.getBLOBFromString("Test content for " + attachment.getName())); attachment.setAttachedAt(new Timestamp(Long.valueOf("1250045365812")));// Arbitrary time // attachment.setAttachedBy(this.taskInstanceFactory.createAssignedUser(TASK_INITIATOR)); attachments.add(attachment);/*from ww w .j av a2 s.c om*/ /* Add second attachment. It accesses an imaginary resource via an URL (i.e. by reference) */ attachment = this.taskInstanceFactory.createAttachment("Attachment2"); // attachment.setAttachedBy(this.taskInstanceFactory.createAssignedUser(TASK_INITIATOR)); attachment.setAccessType(IAttachment.ACCESS_TYPE_REFERENCE); attachment.setContentType("URL"); attachment.setContent(Utilities.getBLOBFromString("http://htm." + attachment.getName() + ".com")); attachment.setAttachedAt(new Timestamp(Long.valueOf("1250045363814")));// Arbitrary time //attachment.setAttachedBy(this.taskInstanceFactory.createAssignedUser(TASK_INITIATOR)); attachments.add(attachment); return attachments; }