List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:cn.org.once.cstack.controller.ScriptingController.java
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON) public @ResponseBody JsonNode scriptingSave(@RequestBody ScriptRequest scriptRequest) throws ServiceException, IOException, CheckException { logger.info("Save"); User user = authentificationUtils.getAuthentificatedUser(); try {//w ww. j a v a2 s.c o m if (scriptRequest.getScriptName().isEmpty() || scriptRequest.getScriptContent().isEmpty()) throw new CheckException("Name or content cannot be empty"); Script script = new Script(); List<Script> scripts = scriptingService.loadAllScripts(); for (Script script1 : scripts) { if (script1.getTitle().equals(scriptRequest.getScriptName())) throw new CheckException("Script name already exists"); } Date now = new Timestamp(Calendar.getInstance().getTimeInMillis()); script.setCreationUserId(user.getId()); script.setTitle(scriptRequest.getScriptName()); script.setContent(scriptRequest.getScriptContent()); script.setCreationDate(now); scriptingService.save(script); ObjectMapper mapper = new ObjectMapper(); JsonNode rootNode = mapper.createObjectNode(); ((ObjectNode) rootNode).put("id", script.getId()); ((ObjectNode) rootNode).put("title", script.getTitle()); ((ObjectNode) rootNode).put("content", script.getContent()); ((ObjectNode) rootNode).put("creation_date", script.getCreationDate().toString()); ((ObjectNode) rootNode).put("creation_user", user.getFirstName() + " " + user.getLastName()); return rootNode; } finally { authentificationUtils.allowUser(user); } }
From source file:com.bdx.rainbow.spsy.controller.syjg.LicenseController.java
@RequestMapping("/excelOut") public void companyInfoExcelOut(HttpServletRequest request, HttpServletResponse response) { DubboEnterpriseLicense condition = new DubboEnterpriseLicense(); condition.setEnterpriseName(request.getParameter("enterpriseName")); condition.setLicenseCode(request.getParameter("licenseCode")); condition.setOrganizationCode(request.getParameter("organizationCode")); if (StringUtils.isNotBlank(request.getParameter("validDateStart"))) { condition.setValidDateStart(DateUtil.getTimestamp(request.getParameter("validDateStart"))); }/* w ww. java 2s. com*/ if (StringUtils.isNotBlank(request.getParameter("validDateEnd"))) { condition.setValidDateEnd(DateUtil.getTimestamp(request.getParameter("validDateEnd"))); } String type = request.getParameter("type") == null ? "" : request.getParameter("type"); if ("0".equals(type)) { condition.setInvalidDateStart(DateUtil.getCurrent()); } else if ("1".equals(type)) { condition.setInvalidDateStart(DateUtil.getCurrent()); condition.setInvalidDateEnd(new Timestamp(DateUtil.addMonth(new Date(), 1).getTime())); } else if ("-1".equals(type)) { condition.setInvalidDateEnd(DateUtil.getCurrent()); } Map<String, Object> resultMap = new HashMap<String, Object>(); try { resultMap = licenseService.getLicenses(condition, -1, 0); String title = "???"; String[] headers = { "???", "?", "", "??", "??", "???", "", "??" }; HSSFWorkbook wb = licenseService.ExcelOut(title, headers, (List<DubboEnterpriseLicense>) resultMap.get("list"), null); response.setContentType("application/vnd.ms-excel"); String fileName = "licenses.xls"; response.setHeader("Content-disposition", "attachment;filename=" + fileName); OutputStream ouputStream = response.getOutputStream(); wb.write(ouputStream); ouputStream.flush(); ouputStream.close(); } catch (Exception e) { log.debug(e.getMessage(), e); } }
From source file:com.google.api.ads.adwords.awalerting.sampleimpl.action.SqlDbPersister.java
/** * Process a report entry, and insert information into database. * //from w w w . j a v a2 s . c o m * @param entry the report entry to process */ @Override public void processReportEntry(UnmodifiableReportRow entry) { Timestamp timestamp = new Timestamp(new Date().getTime()); String clientCustomerIdStr = entry.getFieldValue("ExternalCustomerId"); Long clientCustomerId = null; if (clientCustomerIdStr != null) { clientCustomerId = Long.valueOf(clientCustomerIdStr.replaceAll("-", "")); } String accountName = entry.getFieldValue("AccountDescriptiveName"); String accountManagerName = entry.getFieldValue("AccountManagerName"); String accountManagerEmail = entry.getFieldValue("AccountManagerEmail"); String alertMessage = entry.getFieldValue("AlertMessage"); batchArgs.add(new Object[] { timestamp, clientCustomerId, accountName, accountManagerName, accountManagerEmail, alertMessage }); insertionsCount++; if (batchedInsertions++ >= BATCH_INSERTION_SIZE) { commitBatch(); } }
From source file:kuona.jenkins.analyser.JenkinsProcessor.java
public void collectMetrics(BuildMetrics metrics) { try {/*from w w w. j a v a2s .com*/ Utils.puts("Updating " + getURI()); final int[] jobCount = { 0 }; final int[] buildCount = { 0 }; Set<String> jobNames = getJobs().keySet(); jobCount[0] = jobNames.size(); jobNames.stream().forEach(key -> { try { JobWithDetails job = getJob(key); Utils.puts("Updating " + key); final List<Build> builds = job.details().getBuilds(); buildCount[0] += builds.size(); builds.stream().forEach(buildDetails -> { try { final BuildWithDetails details = buildDetails.details(); Timestamp timestamp = new Timestamp(details.getTimestamp()); Date buildDate = new Date(timestamp.getTime()); int year = buildDate.getYear() + 1900; if (!metrics.activity.containsKey(year)) { metrics.activity.put(year, new int[12]); } int[] yearMap = metrics.activity.get(year); yearMap[buildDate.getMonth()] += 1; if (details.getResult() == null) { metrics.buildCountsByResult.put(BuildResult.UNKNOWN, metrics.buildCountsByResult.get(BuildResult.UNKNOWN) + 1); } else { metrics.buildCountsByResult.put(details.getResult(), metrics.buildCountsByResult.get(details.getResult()) + 1); } metrics.byDuration.collect(details.getDuration()); final List<Map> actions = details.getActions(); actions.stream().filter(action -> action != null).forEach(action -> { if (action.containsKey("causes")) { List<HashMap> causes = (List<HashMap>) action.get("causes"); causes.stream().filter(cause -> cause.containsKey("shortDescription")) .forEach(cause -> { metrics.triggers.add((String) cause.get("shortDescription")); }); } }); metrics.completedBuilds.add(details); } catch (IOException e) { e.printStackTrace(); } }); } catch (IOException e) { e.printStackTrace(); } }); metrics.dashboardServers.add(new HashMap<String, Object>() { { MainView serverInfo = getServerInfo(); put("name", serverInfo.getName()); put("description", serverInfo.getDescription()); put("uri", getURI().toString()); put("jobs", jobCount[0]); put("builds", buildCount[0]); } }); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.rogchen.common.xml.UtilDateTime.java
public static Timestamp addDaysToTimestamp(Timestamp start, Double days) { return new Timestamp(start.getTime() + ((int) (24L * 60L * 60L * 1000L * days))); }
From source file:libepg.epg.util.datetime.DateTimeFieldConverterTest.java
/** * Test of BytesToSqlDateTime method, of class DateTimeFieldConverter. * * @throws java.lang.Exception/*from ww w .j av a 2s . c o m*/ */ @Test public void testBytesTOSqlDateTime2() throws Exception { LOG.info("BytesTOSqlDateTime2"); byte[] source = Hex.decodeHex("e07c180000".toCharArray()); Timestamp expResult = new Timestamp( new java.text.SimpleDateFormat("yyyyMMddHHmmss").parse("20160321180000").getTime()); Timestamp result = DateTimeFieldConverter.BytesToSqlDateTime(source); assertEquals(expResult, result); }
From source file:com.easecargo.awb.HAWBController.java
public static HAWB buildHAWB() { HAWB hAWB = new HAWB(); //hAWB.setAwb(awb) //AWB awb = new AWB(); hAWB.setAwbNumber(22334567);// ww w . j a va2s . co m hAWB.setAwbPrefix(124); //hAWB.setAwb(awb); hAWB.setCharge("23"); hAWB.setContactPerson("Gikenson"); hAWB.setContactPhone("24443222"); hAWB.setCurrency("EUR"); hAWB.setDeclaredValueCarrier(32.2f); hAWB.setDeclaredValueCustomer(23.3f); hAWB.setDepartureAirportCode("LHR"); hAWB.setDestinationAirportCode("YUL"); hAWB.setDimensionUnit("M"); hAWB.setFlightDate(new Timestamp(new Date().getTime())); hAWB.setFlightNumber("BA0222"); hAWB.setHarmonizedCode("HAR"); hAWB.setHawbNum("2323333"); hAWB.setHeight(22.4f); hAWB.setInsuredAmount(433.3f); hAWB.setLength(32.4f); hAWB.setNatureOfGoods("Cloths"); hAWB.setOciInfo("no info"); hAWB.setPieces(12); hAWB.setRemarks("No additonal remarks"); hAWB.setWeight(12.4f); hAWB.setVolume(33.5f); hAWB.setWidth(33.5f); hAWB.setTotalGrossWeight(66.7f); hAWB.setTotalGrossWeightUnit("Kg"); hAWB.setTotalPieces(22); hAWB.setTotalShipmentGrossCount(2); Customer shipper = new Customer(); //shipper.setUser(u); shipper.setCustomerName("Fashion"); shipper.setAddress("#10,Nile St. Airport Road"); shipper.setCityName("Madrid"); shipper.setContactName("Gradia"); shipper.setCountryName("Spain"); shipper.setEmail("info@fashion.com"); shipper.setPhoneNumber(82389329);//change integer shipper.setPoBox(1232); shipper.setAccountNumber("233332322"); Customer consignee = new Customer(); //consignee.setUser(u); consignee.setCustomerName("Wild Mart"); consignee.setAddress("#10,Elstra St. Mount Road"); consignee.setCityName("Toronto"); consignee.setContactName("Silvester"); consignee.setCountryName("Canada"); consignee.setEmail("info@wildmart.com"); consignee.setPhoneNumber(82879329);//change integer consignee.setPoBox(1222); consignee.setAccountNumber("88886644"); hAWB.setConsignee(consignee); hAWB.setShipper(shipper); return hAWB; }
From source file:helpers.database.DBAdminManager.java
/** * add a user to the negative spammerlist. So he is marked NOT as a spammer and will not appear longer in any suggestion list * @param bean the AdminBean reference//from ww w . j a v a 2 s . com */ public static void removeUserFromSpammerlist(AdminBean bean) { DBContext c = new DBContext(); try { if (c.init()) { c.stmt = c.conn.prepareStatement("UPDATE user " + " SET " + " spammer_suggest = 0, " + " updated_by = ?, " + " updated_at = ?, " + " to_classify = " + constants.SQL_CONST_TO_CLASSIFY_FALSE + " WHERE user_name = ?"); c.stmt.setString(1, bean.getCurrUser()); c.stmt.setTimestamp(2, new Timestamp(new Date().getTime())); c.stmt.setString(3, bean.getUser()); if (c.stmt.executeUpdate() == 1) { bean.addInfo("user '" + bean.getUser() + "' was removed from spammer suggestion list."); } else { bean.addError("user '" + bean.getUser() + "' could not be removed from the list. The user was not found."); } } } catch (SQLException e) { bean.addError("Sorry, an error occured: " + e); } }
From source file:jp.zippyzip.City.java
/** * ??//from w w w .ja v a2 s . c o m * * @param expiration ? */ public void setExpiration(long expiration) { this.expiration = new Timestamp(expiration); }
From source file:com.mothsoft.alexis.rest.dataset.v1.impl.DataSetResourceImpl.java
@Override public Correlation correlate(Long dataSetAId, Long dataSetBId, Timestamp startDate, Timestamp endDate, String units) {//from ww w.jav a2 s .c o m if (units == null) { final Response response = Response.status(Status.BAD_REQUEST) .entity("Invalid Request: parameter 'units' expected").build(); throw new WebApplicationException(response); } final TimeUnits unitEnum = TimeUnits.valueOf(units); com.mothsoft.alexis.domain.DataSet ds1 = null; com.mothsoft.alexis.domain.DataSet ds2 = null; try { ds1 = this.service.get(dataSetAId); ds2 = this.service.get(dataSetBId); } catch (final EntityNotFoundException nfe) { final Response response = Response.status(Status.BAD_REQUEST).entity("Invalid Request: unknown dataset") .build(); throw new WebApplicationException(response); } if (startDate == null) { final Calendar calendar = new GregorianCalendar(1900, 0, 1); startDate = new Timestamp(calendar.getTime().getTime()); logger.debug("Start Date: " + startDate.toLocaleString()); } if (endDate == null) { endDate = new Timestamp(System.currentTimeMillis()); logger.debug("End Date: " + endDate.toLocaleString()); } return new Correlation(this.service.correlate(ds1, ds2, startDate, endDate, unitEnum)); }