List of usage examples for java.sql Timestamp Timestamp
public Timestamp(long time)
From source file:uk.org.funcube.fcdw.server.extract.csv.WodCsvExtractor.java
@Transactional(readOnly = true, propagation = Propagation.REQUIRED) public void extract(long satelliteId) { Date currentDate = clock.currentDate(); Timestamp latestSatelliteTime = wholeOrbitDataDao.getLatestSatelliteTime(satelliteId); Timestamp since = new Timestamp(latestSatelliteTime.getTime() - (24 * 60 * 60 * 1000)); List<WholeOrbitDataEntity> wod24 = wholeOrbitDataDao.getSinceSatelliteTime(satelliteId, since); if (wod24.size() == 0) { return;/*from ww w . ja v a2 s . co m*/ } File fileLocation = new File(System.getProperty("csv.wod")); if (fileLocation.exists()) { fileLocation.delete(); } writeFile(wod24, fileLocation); }
From source file:org.jasig.portlet.survey.service.jpa.JpaSurveyDao.java
@Override public JpaSurveyQuestion attachQuestionToSurvey(Long surveyId, Long questionId, JpaSurveyQuestion surveyQuestion) { JpaSurvey survey = getSurvey(surveyId); JpaQuestion question = getQuestion(questionId); survey.setLastUpdateDate(new Timestamp(new Date().getTime())); JpaSurveyQuestionPK pk = new JpaSurveyQuestionPK(question, survey); surveyQuestion.setId(pk);/* www. ja va 2 s .co m*/ survey.addJpaSurveyQuestion(surveyQuestion); surveyRepository.save(survey); return surveyQuestion; }
From source file:com.teamglokk.muni.utilities.Transaction.java
/** * Full data constructor//from ww w . ja va 2s .c om * @param instance * @param town_Name * @param player * @param reason * @param payment * @param item_payment */ public Transaction(Muni instance, String town_Name, String player, String reason, double payment, int item_payment, Timestamp stamp) { plugin = instance; playerName = player; townName = town_Name; type = reason; amount = payment; item_amount = item_payment; if (stamp == null) { datetime = new Timestamp(System.currentTimeMillis()); } else { datetime = stamp; } //= Calendar.getInstance(); //time = Calendar.getInstance(); }
From source file:uk.org.funcube.fcdw.server.extract.csv.RealTimeCsvExtractor.java
@Transactional(readOnly = true, propagation = Propagation.REQUIRED) public void extract(long satelliteId) { Date currentDate = clock.currentDate(); Timestamp latestSatelliteTime = realTimeDao.getLatestSatelliteTime(satelliteId); Timestamp since = new Timestamp(latestSatelliteTime.getTime() - (250 * 60 * 1000)); List<RealTimeEntity> realTime12 = realTimeDao.getSinceSatelliteTime(satelliteId, since); if (realTime12.size() == 0) { return;/*w ww . j a v a 2 s . c o m*/ } File fileLocation = new File(System.getProperty("csv.realtime")); if (fileLocation.exists()) { fileLocation.delete(); } try { // use FileWriter constructor that specifies open for appending CsvWriter csvOutput = new CsvWriter(new FileWriter(fileLocation, true), ','); // write out the headers csvOutput.write("Satellite Date/Time UTC"); csvOutput.write("Solar Panel Voltage X mV"); csvOutput.write("Solar Panel Voltage Y mV"); csvOutput.write("Solar Panel Voltage Z mV"); csvOutput.write("Total Photo Current mA"); csvOutput.write("Battery Voltage mV"); csvOutput.write("Total System Current mA"); csvOutput.write("Boost Converter Temp 1 C"); csvOutput.write("Boost Converter Temp 2 C"); csvOutput.write("Boost Converter Temp 3 C"); csvOutput.write("Battery Temp C"); csvOutput.write("Sun Sensor X+"); csvOutput.write("Sun Sensor Y+"); csvOutput.write("Sun Sensor Z+"); csvOutput.write("Solar Panel Temp X+ C"); csvOutput.write("Solar Panel Temp X- C"); csvOutput.write("Solar Panel Temp Y+ C"); csvOutput.write("Solar Panel Temp Y- C"); csvOutput.write("3.3 Bus Voltage mV"); csvOutput.write("3.3 Bus Current mA"); csvOutput.write("5.0 Bus Voltage mV"); csvOutput.write("RF Temperature C"); csvOutput.write("Receive Current mA"); csvOutput.write("RF Current 3.3V Bus mA"); csvOutput.write("RF Current 5.0V Bus mA"); csvOutput.write("PA Device Temperature C"); csvOutput.write("PA Bus Current mA"); csvOutput.write("Antenna Temp 0 C"); csvOutput.write("Antenna Temp 1 C"); csvOutput.endRecord(); long tsLong = 0; String c1 = ""; String c2 = ""; String c3 = ""; String c4 = ""; String c5 = ""; String c6 = ""; String c7 = ""; String c8 = ""; String c9 = ""; String c10 = ""; String c11 = ""; String c12 = ""; String c13 = ""; String c14 = ""; String c15 = ""; String c16 = ""; String c17 = ""; String c18 = ""; String c19 = ""; String c20 = ""; String c21 = ""; String c22 = ""; String c23 = ""; String c24 = ""; String c25 = ""; String c26 = ""; String c27 = ""; String c28 = ""; String c29 = ""; for (RealTimeEntity entity : realTime12) { Timestamp satelliteTime = entity.getSatelliteTime(); if (tsLong == 0) { tsLong = satelliteTime.getTime(); // Solar Panel Voltage X mV c1 = String.format("%4d", entity.getC1()); // Solar Panel Voltage Y mV c2 = String.format("%4d", entity.getC2()); // Solar Panel Voltage Z mV c3 = String.format("%4d", entity.getC3()); // Total Photo Current mA c4 = String.format("%4d", entity.getC4()); // Battery Voltage mV c5 = String.format("%4d", entity.getC5()); // Total System Current mA c6 = String.format("%4d", entity.getC6()); // Boost Converter Temp 1 C c7 = String.format("%4d", twosComplement(entity.getC9())); // Boost Converter Temp 2 C c8 = String.format("%4d", twosComplement(entity.getC10())); // Boost Converter Temp 3 C c9 = String.format("%4d", twosComplement(entity.getC11())); // Battery Temp C c10 = String.format("%4d", twosComplement(entity.getC12())); // Sun Sensor X+ c11 = String.format("%4.2f", SOL_ILLUMINATION[entity.getC17().intValue()]); // Sun Sensor Y+ c12 = String.format("%4.2f", SOL_ILLUMINATION[entity.getC18().intValue()]); // Sun Sensor Z+ c13 = String.format("%4.2f", SOL_ILLUMINATION[entity.getC19().intValue()]); // Solar Panel Temp X+ C c14 = scale(entity.getC20(), -0.2073, 158.239); // Solar Panel Temp X- C c15 = scale(entity.getC21(), -0.2083, 159.227); // Solar Panel Temp Y+ C c16 = scale(entity.getC22(), -0.2076, 158.656); // Solar Panel Temp Y- C c17 = scale(entity.getC23(), -0.2087, 159.045); // 3.3 Bus Voltage mV c18 = scale(entity.getC24(), 4.0, 0.0); // 3.3 Bus Current mA c19 = scale(entity.getC25(), 1.0, 0.0); // 5.0 Bus Voltage mV c20 = scale(entity.getC26(), 6.0, 0.0); // RF Temperature C c21 = scale(entity.getC34(), -0.857, 193.672); // Receive Current mA c22 = String.format("%4d", entity.getC35()); // RF Current 3.3V Bus mA c23 = String.format("%4d", entity.getC36()); // RF Current 5.0V Bus mA c24 = String.format("%4d", entity.getC37()); // PA Device Temperature C c25 = String.format("%4.1f", getPaTemp(entity.getC40())); // PA Bus Current mA c26 = String.format("%4.1f", getPaCurrent(entity.getC41())); // Antenna Temp 0 C c27 = String.format("%5.1f", getAntsTemp(entity.getC42().intValue())); // Antenna Temp 1 C c28 = String.format("%5.1f", getAntsTemp(entity.getC43().intValue())); writeRecord(csvOutput, satelliteTime, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28); } else { final long timeDiff = satelliteTime.getTime() - tsLong; if (timeDiff > 5000) { // fill in the gaps long gaps = (timeDiff / 5000); for (long i = 1; i < gaps; i++) { Timestamp intervalTime = new Timestamp(tsLong + (5000 * i)); writeRecord(csvOutput, intervalTime, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28); } } // Solar Panel Voltage X mV c1 = String.format("%4d", entity.getC1()); // Solar Panel Voltage Y mV c2 = String.format("%4d", entity.getC2()); // Solar Panel Voltage Z mV c3 = String.format("%4d", entity.getC3()); // Total Photo Current mA c4 = String.format("%4d", entity.getC4()); // Battery Voltage mV c5 = String.format("%4d", entity.getC5()); // Total System Current mA c6 = String.format("%4d", entity.getC6()); // Boost Converter Temp 1 C c7 = String.format("%4d", twosComplement(entity.getC9())); // Boost Converter Temp 2 C c8 = String.format("%4d", twosComplement(entity.getC10())); // Boost Converter Temp 3 C c9 = String.format("%4d", twosComplement(entity.getC11())); // Battery Temp C c10 = String.format("%4d", twosComplement(entity.getC12())); // Sun Sensor X+ c11 = String.format("%4.2f", SOL_ILLUMINATION[entity.getC17().intValue()]); // Sun Sensor Y+ c12 = String.format("%4.2f", SOL_ILLUMINATION[entity.getC18().intValue()]); // Sun Sensor Z+ c13 = String.format("%4.2f", SOL_ILLUMINATION[entity.getC19().intValue()]); // Solar Panel Temp X+ C c14 = scale(entity.getC20(), -0.2073, 158.239); // Solar Panel Temp X- C c15 = scale(entity.getC21(), -0.2083, 159.227); // Solar Panel Temp Y+ C c16 = scale(entity.getC22(), -0.2076, 158.656); // Solar Panel Temp Y- C c17 = scale(entity.getC23(), -0.2087, 159.045); // 3.3 Bus Voltage mV c18 = scale(entity.getC24(), 4.0, 0.0); // 3.3 Bus Current mA c19 = scale(entity.getC25(), 1.0, 0.0); // 5.0 Bus Voltage mV c20 = scale(entity.getC26(), 6.0, 0.0); // RF Temperature C c21 = scale(entity.getC34(), -0.857, 193.672); // Receive Current mA c22 = String.format("%4d", entity.getC35()); // RF Current 3.3V Bus mA c23 = String.format("%4d", entity.getC36()); // RF Current 5.0V Bus mA c24 = String.format("%4d", entity.getC37()); // PA Device Temperature C c25 = String.format("%4.1f", getPaTemp(entity.getC40())); // PA Bus Current mA c26 = String.format("%4.1f", getPaCurrent(entity.getC41())); // Antenna Temp 0 C c27 = String.format("%5.1f", getAntsTemp(entity.getC42().intValue())); // Antenna Temp 1 C c28 = String.format("%5.1f", getAntsTemp(entity.getC43().intValue())); writeRecord(csvOutput, satelliteTime, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28); tsLong = satelliteTime.getTime(); } } csvOutput.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.matrimony.controller.ProfileController.java
@RequestMapping(value = "updateBasicProfile", method = RequestMethod.POST, produces = "application/json; charset=utf-8") @ResponseBody//from w w w.java 2s . c o m public String updateBasicProfile(HttpServletRequest request, HttpServletResponse response, User userBasic) { User ssUser = (User) request.getSession().getAttribute("user"); if (ssUser == null) return null; Timestamp currentTime = new Timestamp(System.currentTimeMillis()); Properties props = new Properties(); boolean wellForm = true; System.out.println(userBasic.getEmail()); StringResouces sr = new StringResouces(StringResouces.vi_VN); if (!Pattern.matches(Regex.NAME, userBasic.getFirstName())) { wellForm = false; props.put("txtFirstName", sr.getData().get("firstNameInvalid")); } if (!Pattern.matches(Regex.NAME, userBasic.getLastName())) { wellForm = false; props.put("txtLastName", sr.getData().get("lastNameInvalid")); } if (!Pattern.matches(Regex.EMAIL, userBasic.getEmail())) { wellForm = false; props.put("txtEmail", sr.getData().get("emailInvalid")); } if (!Pattern.matches(Regex.PHONE, userBasic.getContactNumber())) { wellForm = false; props.put("txtPhone", sr.getData().get("phoneInvalid")); } if (!"12345678".equals(userBasic.getPassword())) { if (!Pattern.matches(Regex.PASSWORD, userBasic.getPassword())) { wellForm = false; props.put("txtPassword", sr.getData().get("passwordInvalid")); } } if (wellForm) { ssUser.setUsername(userBasic.getUsername()); ssUser.setLastName(userBasic.getLastName()); ssUser.setFirstName(userBasic.getFirstName()); ssUser.setMiddleName(userBasic.getMiddleName()); ssUser.setName(ssUser.getLastName() + " " + ssUser.getMiddleName() + " " + ssUser.getFirstName()); ssUser.setEmail(userBasic.getEmail()); System.out.println(userBasic.getPassword()); if (!"12345678".equals(userBasic.getPassword())) { ssUser.setPassword(userBasic.getPassword()); ssUser.setSalt(null); } ssUser.setUpdateTime(currentTime); UserDAO.Update(ssUser); } props.put("wellForm", wellForm); String json = Global.gson.toJson(props); System.out.println(json); return json; }
From source file:com.cyw.common.util.bean.DateConverter.java
protected Object convertToDate(Class type, Object value, String pattern) { DateFormat df = new SimpleDateFormat(pattern); if (value instanceof String) { try {//from w w w. j av a2 s. com if (StringUtils.isEmpty(value.toString())) { return null; } Date date = df.parse((String) value); if (type.equals(Timestamp.class)) { return new Timestamp(date.getTime()); } return date; } catch (Exception pe) { pe.printStackTrace(); throw new ConversionException("Error converting String to Date"); } } else if (value instanceof Timestamp) { try { Timestamp timestamp = (Timestamp) value; Date date = new Date(timestamp.getTime()); return date; } catch (Exception pe) { pe.printStackTrace(); throw new ConversionException("Error converting Timestamp to Date"); } } else if (value instanceof java.sql.Date) { try { java.sql.Date sqlDate = (java.sql.Date) value; return new Date(sqlDate.getTime()); } catch (Exception pe) { pe.printStackTrace(); throw new ConversionException("Error converting String to Date"); } } else if (value instanceof Date) { return value; } throw new ConversionException("Could not convert " + value.getClass().getName() + " to " + type.getName()); }
From source file:edu.duke.cabig.c3pr.domain.User.java
@Column(name = "password_last_set") public Timestamp getPasswordLastSet() { return passwordLastSet == null ? new Timestamp(0) : passwordLastSet; }
From source file:gda.scan.MultiScanRunner.java
@Override public void runScan() throws InterruptedException, Exception { try {/*from w w w. jav a 2s .c om*/ setStatus(ScanStatus.RUNNING); if (LocalProperties.check(ScanBase.GDA_SCANBASE_PRINT_TIMESTAMP_TO_TERMINAL)) { java.util.Date date = new java.util.Date(); getTerminalPrinter() .print("=== Scan started at " + new Timestamp(date.getTime()).toString() + " ==="); } for (MultiScanItem item : scans) { TotalNumberOfPoints += item.scan.getTotalNumberOfPoints(); } MultiScanItem multiScanItem = scans.get(0); first = multiScanItem.scan; first.prepareScanForCollection(); int pointCount = -1; for (MultiScanItem item : scans) { ScanBase scan = item.scan; lastscan = scan; for (Detector det : scan.getDetectors()) { if (det instanceof HardwareTriggeredDetector) { ((HardwareTriggeredDetector) det).setNumberImagesToCollect(scan.getTotalNumberOfPoints()); } } scan.setIsChild(true); scan.setParent(this); scan.setScanDataPointPipeline(first.getScanDataPointPipeline()); scan.setScanNumber(first.getScanNumber()); // run the scan scan.currentPointCount = pointCount; scan.name = first.name; Runnable prescan = item.prescan; if (prescan != null) { prescan.run(); } scan.callScannablesAtScanStart(); scan.run(); pointCount = scan.currentPointCount; } for (MultiScanItem item : scans) { ScanBase scan = item.scan; scan.callScannablesAtScanEnd(); scan.callDetectorsEndCollection(); } if (lastscan != null) { lastscan.shutdownScandataPipeline(true); } } catch (Exception e) { logger.error("Error running multiScan", e); if (lastscan != null) { lastscan.shutdownScandataPipeline(false); } throw e; } finally { switch (getStatus()) { case RUNNING: setStatus(ScanStatus.COMPLETED_OKAY); break; case TIDYING_UP_AFTER_FAILURE: setStatus(ScanStatus.COMPLETED_AFTER_FAILURE); break; case TIDYING_UP_AFTER_STOP: setStatus(ScanStatus.COMPLETED_AFTER_STOP); break; case FINISHING_EARLY: setStatus(ScanStatus.COMPLETED_EARLY); break; default: throw new AssertionError("Unexpected status at the end of scan:" + getStatus().toString()); } if (lastscan != null) { lastscan.signalScanComplete(); } } }
From source file:com.asakusafw.testdriver.BatchTestDriver.java
/** * ?????????/*from w w w .j a v a2 s. com*/ * @param batchDescriptionClass ??? */ public void runTest(Class<? extends BatchDescription> batchDescriptionClass) { try { JobflowExecutor executor = new JobflowExecutor(driverContext); // ? executor.cleanWorkingDirectory(); // ???Excel??? storeDatabase(); setLastModifiedTimestamp(new Timestamp(0L)); // ??? BatchDriver batchDriver = BatchDriver.analyze(batchDescriptionClass); assertFalse(batchDriver.getDiagnostics().toString(), batchDriver.hasError()); File compileWorkDir = driverContext.getCompilerWorkingDirectory(); if (compileWorkDir.exists()) { FileUtils.forceDelete(compileWorkDir); } File compilerOutputDir = new File(compileWorkDir, "output"); File compilerLocalWorkingDir = new File(compileWorkDir, "build"); BatchInfo batchInfo = DirectBatchCompiler.compile(batchDescriptionClass, "test.batch", Location.fromPath(driverContext.getClusterWorkDir(), '/'), compilerOutputDir, compilerLocalWorkingDir, Arrays.asList(new File[] { DirectFlowCompiler.toLibraryPath(batchDescriptionClass) }), batchDescriptionClass.getClassLoader(), driverContext.getOptions()); for (JobflowInfo jobflowInfo : batchInfo.getJobflows()) { driverContext.prepareCurrentJobflow(jobflowInfo); executor.runJobflow(jobflowInfo); } // ???Excel??DB?? loadDatabase(); if (!testUtils.inspect()) { Assert.fail(testUtils.getCauseMessage()); } } catch (IOException e) { throw new RuntimeException(e); } finally { driverContext.cleanUpTemporaryResources(); } }
From source file:rmblworx.tools.timey.persistence.dao.AlarmDao.java
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public Boolean createAlarm(final AlarmDescriptor descriptor) { Boolean result = Boolean.FALSE; if (descriptor != null) { try {/*ww w.ja va 2s .c om*/ final AlarmEntity entity = new AlarmEntity(); final Timestamp timestamp = new Timestamp(descriptor.getAlarmtime().getMilliSeconds()); final String sound = descriptor.getSound(); Timestamp snooze = null; if (descriptor.getSnooze() != null) { snooze = new Timestamp(descriptor.getSnooze().getMilliSeconds()); } entity.setAlarm(timestamp); entity.setIsActivated(descriptor.getIsActive()); entity.setDescription(descriptor.getDescription()); entity.setSnooze(snooze); entity.setSound(sound); this.currentSession().save(entity); result = Boolean.TRUE; } catch (final Exception e) { this.logError(e); } } // TODO: Noch umzusetzen : Jeder Zeitpunkt darf nur von einem Alarm beschrieben und persistent sein return result; }