List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:com.lm.lic.manager.controller.GenerateLicensesPerPayController.java
private List<License> extractRawLicenses(HttpServletRequest req, List<String> licKeys, int lifeInDays, LicenseBlock lb, Isv isv, Product product) { List<License> licenses = new ArrayList<License>(licKeys.size()); for (String lk : licKeys) { boolean inUse = false; String endUserName = StringUtils.EMPTY; String endUserCell = StringUtils.EMPTY; String endUserPin = StringUtils.EMPTY; Calendar calendar = Calendar.getInstance(); Timestamp dateIssued = new Timestamp(calendar.getTimeInMillis()); calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 10); Timestamp dateActivated = new Timestamp(calendar.getTimeInMillis()); Timestamp dateExpires = new Timestamp(calendar.getTimeInMillis()); Boolean decom = false;/*from w w w .j a va 2s .c o m*/ String decomReason = DecomLicenseReason.NOT_YET.name(); String shadowLicKey = GenUtil.EMPTY; Double cost = lb.getPricePerLicense(); Double price = lb.getPricePerLicense(); String localeLang = BaseLicenseManagerFormController.extractLocaleLang(req); License lic = new License(lb, isv, product, null, inUse, lk, lifeInDays, decom, decomReason, shadowLicKey, LicensePaymentStatus.PAID_GEN.name(), endUserName, endUserCell, endUserPin, dateIssued, dateActivated, dateExpires, cost, price, localeLang, GenUtil.DEFAULT_USER, GenUtil.CURRENT_TIME, GenUtil.DEFAULT_USER, GenUtil.CURRENT_TIME); licenses.add(lic); } return licenses; }
From source file:edu.utah.further.mdr.ws.api.to.ActivationInfoToImpl.java
/** * @param other/*from w w w. java2s .c o m*/ * @return * @see edu.utah.further.mdr.api.domain.asset.ActivationInfo#copyFrom(edu.utah.further.mdr.api.domain.asset.ActivationInfo) */ @Override public ActivationInfoToImpl copyFrom(final ActivationInfo other) { if (other == null) { return this; } // Identifier is not copied // Deep-copy fields final Timestamp otherActivationDate = other.getActivationDate(); if (otherActivationDate != null) { this.activationDate = new Timestamp(otherActivationDate.getTime()); } final Timestamp otherDeactivationDate = other.getDeactivationDate(); if (otherDeactivationDate != null) { this.deactivationDate = new Timestamp(otherDeactivationDate.getTime()); } // Deep-copy collection references but soft-copy their elements return this; }
From source file:com.aionemu.gameserver.model.gameobjects.BrokerItem.java
public void removeItem() { //this.item = null; this.isSold = true; this.isSettled = true; this.settleTime = new Timestamp(Calendar.getInstance().getTimeInMillis()); }
From source file:com.daon.identityx.controller.TestController.java
/*** * UNPROTECTED OPERATION - No session is required to perform this operation * This operation is only to allow for testing with an UNAUTHENTICATED REST client. * It returns details of the account requested. * /*ww w .ja v a2 s. co m*/ * @param anId * @return */ @RequestMapping(value = "accounts/{id}", method = RequestMethod.GET) @ResponseStatus(value = HttpStatus.OK) public @ResponseBody Account getAccount(@PathVariable("id") String anId) { long start = System.currentTimeMillis(); Audit anAudit = new Audit(AuditAction.GET_ACCOUNT); anAudit.setAccountId(anId); try { Account account = this.getAccountRepository().findById(anId); if (account == null) { throw new ProcessingException(Error.ACCOUNT_NOT_FOUND); } return account; } finally { anAudit.setDuration(System.currentTimeMillis() - start); anAudit.setCreatedDTM(new Timestamp(System.currentTimeMillis())); this.getAuditRepository().save(anAudit); } }
From source file:com.invoiced.entity.SubscriptionTest.java
@Test public void testJsonSerialization() { Subscription cust = new Subscription(null); ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);/*from ww w. ja v a2 s . c om*/ try { String jsonString = "{\n \"id\": 595,\n \"customer\": 15444,\n \"plan\": \"starter\",\n \"cycles\": null,\n \"quantity\": 1,\n \"start_date\": 1420391704,\n \"period_start\": 1446657304,\n \"period_end\": 1449249304,\n \"cancel_at_period_end\": false,\n \"canceled_at\": null,\n \"status\": \"active\",\n \"addons\": [\n {\n \"id\": 3,\n \"catalog_item\": \"ipad-license\",\n \"quantity\": 11,\n \"created_at\": 1420391704\n }\n ],\n \"discounts\": [],\n \"taxes\": [],\n \"url\": \"https://dundermifflin.invoiced.com/subscriptions/o2mAd2wWVfYy16XZto7xHwXX\",\n \"created_at\": 1420391704,\n \"metadata\": {}\n}"; Subscription s1 = mapper.readValue(jsonString, Subscription.class); assertTrue("Id is incorrect", s1.id == 595L); assertTrue("Customer is incorrect", s1.customer == 15444L); assertTrue("Plan is incorrect", s1.plan.equals("starter")); assertTrue("Cycles is incorrect", s1.cycles == 0); assertTrue("Quantity is incorrect", s1.quantity == 1); assertTrue("Start Date is incorrect", s1.startDate.equals(new Timestamp(1420391704L))); assertTrue("Period Start is incorrect", s1.periodStart.equals(new Timestamp(1446657304L))); assertTrue("Period End is incorrect", s1.periodEnd.equals(new Timestamp(1449249304L))); assertTrue("Cancel At Period End is incorrect", s1.cancelAtPeriodEnd == false); assertTrue("Canceled At incorrect", s1.canceledAt == null); assertTrue("Status is incorrect", s1.status.equals("active")); assertTrue("Addons is incorrect", s1.addons.length > 0); assertTrue("Discounts is incorrect", s1.discounts.length == 0); assertTrue("Taxes is incorrect", s1.taxes.length == 0); assertTrue("Url is incorrect", s1.url.equals("https://dundermifflin.invoiced.com/subscriptions/o2mAd2wWVfYy16XZto7xHwXX")); assertTrue("Created At is incorrect", s1.createdAt.equals(new Timestamp(1420391704))); assertTrue("Metadata is incorrect", s1.metadata != null); assertTrue("Addon id is incorrect", s1.addons[0].id == 3); } catch (JsonGenerationException e) { e.printStackTrace(); fail(); } catch (JsonMappingException e) { e.printStackTrace(); fail(); } catch (IOException e) { e.printStackTrace(); fail(); } }
From source file:com.wolvencraft.yasp.util.Util.java
/** * Returns the current time in seconds./* www . j a v a 2 s.c om*/ * * @return Current time */ public static long getTimestamp() { Timestamp timestamp = new Timestamp(new java.util.Date().getTime()); return timestamp.getTime() / 1000; }
From source file:mitll.xdata.dataset.kiva.ingest.KivaIngest.java
public static int executePreparedStatement(PreparedStatement statement, List<String> types, List<String> values) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); try {/*from ww w .j a v a 2s . c om*/ for (int i = 0; i < types.size(); i++) { String type = TYPE_TO_DB.get(types.get(i).toUpperCase()); String value = values.get(i); if (value != null && value.trim().length() == 0) { value = null; } if (type.equalsIgnoreCase("INT")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.INTEGER); } else { statement.setInt(i + 1, Integer.parseInt(value, 10)); } } else if (type.equalsIgnoreCase("DOUBLE")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.DOUBLE); } else { statement.setDouble(i + 1, Double.parseDouble(value)); } } else if (type.equalsIgnoreCase("BOOLEAN")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.BOOLEAN); } else { statement.setBoolean(i + 1, Boolean.parseBoolean(value)); } } else if (type.equalsIgnoreCase("VARCHAR")) { statement.setString(i + 1, value); } else if (type.equalsIgnoreCase("TIMESTAMP")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.TIMESTAMP); } else { statement.setTimestamp(i + 1, new Timestamp(sdf.parse(value).getTime())); } } } } catch (Throwable e) { System.out.println("types = " + types); System.out.println("values = " + values); System.out.println("types.size() = " + types.size()); System.out.println("values.size() = " + values.size()); e.printStackTrace(); System.out.println(e.getMessage()); throw new Exception(e); } return statement.executeUpdate(); }
From source file:daos.BetalingDaoTest.java
@Test public void testFindBetaling() { LOG.info("findBetalingTest"); Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();//w w w . ja v a 2 s .c o m testBetaling.setBetaalDatum(new Timestamp(date.getTime())); testBetaling.setBetaalwijze(bw); testBetaling.setKlant(klant); testBetaling.setFactuur(f1); session.save(testBetaling); session.getTransaction().commit(); session.close(); instance.readEntity(1); assertEquals("id moet gelijk zijn", new Integer(1), ((Betaling) instance.readEntity(1)).getIdBetaling()); }
From source file:fr.paris.lutece.portal.web.admin.AdminPageJspBeanTest.java
@Override protected void setUp() throws Exception { super.setUp(); _randomPageName = "page" + new SecureRandom().nextLong(); IPageService pageService = (IPageService) SpringContextService.getBean("pageService"); _page = new Page(); _page.setParentPageId(PortalService.getRootPageId()); _page.setPageTemplateId(PageTemplateHome.getPageTemplatesList().get(0).getId()); _page.setName(_randomPageName);// w ww .j a va2 s .c o m _page.setDescription(_randomPageName); _page.setMetaKeywords(""); _page.setMetaDescription(""); _page.setNodeStatus(1); _page.setDateUpdate(new Timestamp(new java.util.Date().getTime())); _page.setDisplayDateUpdate(true); _page.setIsManualDateUpdate(true); pageService.createPage(_page); _bean = new AdminPageJspBean(); _adminUser = getAdminUser(); }