List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:com.hihframework.core.utils.DateUtils.java
public static String getDateTimeString(java.sql.Date dd) { if (dd == null) { return ""; }//from w ww.java 2 s .c o m String tds = dd.toString(); java.sql.Time tt = new java.sql.Time(dd.getTime()); tds += (" " + tt.toString()); return tds; }
From source file:com.google.code.ssm.test.dao.TestDAOImpl.java
@Override @ReadThroughSingleCache(namespace = CacheConst.ALPHA, expiration = 30) public String getDateString(@ParameterValueKeyProvider final String key) { final Date now = new Date(); try {/*from ww w .j a v a 2 s . co m*/ Thread.sleep(1500); } catch (InterruptedException ex) { } return now.toString() + ":" + now.getTime(); }
From source file:com.mothsoft.alexis.engine.numeric.TopicActivityDataSetImporter.java
private void recordAggregateTopicActivity(final Long userId, final Date startDate, final BigInteger total) { logger.debug("Recording aggregate topic activity for user: " + userId + "; (" + startDate.toString() + ", " + total + ")"); this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override/*w w w . ja va2 s .c o m*/ protected void doInTransactionWithoutResult(TransactionStatus txStatus) { DataSet dataSet = TopicActivityDataSetImporter.this.dataSetDao .findAggregateTopicActivityDataSet(userId); if (dataSet == null) { final DataSetType type = TopicActivityDataSetImporter.this.dataSetTypeDao .findSystemDataSetType(DataSetType.TOPIC_ACTIVITY); dataSet = new DataSet(userId, "*All Topics*", type, true); TopicActivityDataSetImporter.this.dataSetDao.add(dataSet); } final DataSetPoint totalPoint = new DataSetPoint(dataSet, startDate, total.doubleValue()); TopicActivityDataSetImporter.this.dataSetPointDao.add(totalPoint); } }); }
From source file:com.hihframework.core.utils.DateUtils.java
public static String getDateString(java.sql.Date dd) { if (dd == null) { return ""; }//from www .jav a2 s . c o m String tds = dd.toString(); String temp = ""; for (int x = 0; x < tds.length(); x++) { if (tds.charAt(x) != '-') { temp = temp + tds.charAt(x); } } return temp; }
From source file:com.github.seqware.queryengine.tutorial.PosterSGE.java
/** * <p>benchmark.</p>// ww w.j a va 2 s. com * * @throws java.io.IOException if any. */ public void benchmark() throws IOException { if (args.length != 3) { System.err.println(args.length + " arguments found"); System.out.println( PosterSGE.class.getSimpleName() + " <outputKeyValueFile> <input file dir> <simultaneous jobs>"); System.exit(-1); } File outputFile = Utility.checkOutput(args[0]); // check if reference has been properly created Reference reference = SWQEFactory.getQueryInterface().getLatestAtomByRowKey("hg_19", Reference.class); if (reference == null) { SGID refID = ReferenceCreator.mainMethod(new String[] { HG_19 }); reference = SWQEFactory.getQueryInterface().getAtomBySGID(Reference.class, refID); } // record reference, starting disk space keyValues.put("referenceID", reference.getSGID().getRowKey()); recordSpace("start"); Utility.writeKeyValueFile(outputFile, keyValues); // create new FeatureSet id and pass it onto our children CreateUpdateManager manager = SWQEFactory.getModelManager(); FeatureSet initialFeatureSet = manager.buildFeatureSet().setReference(reference).build(); manager.flush(); int count = 0; // go through all input files File fileDirectory = new File(args[1]); File[] listFiles = fileDirectory.listFiles(); // record start and finish time Date startDate = new Date(); keyValues.put(count + "-start-date-long", Long.toString(startDate.getTime())); keyValues.put(count + "-start-date-human", startDate.toString()); // submit all jobs in parallel via SGE StringBuilder jobNames = new StringBuilder(); for (File inputFile : listFiles) { // run without unnecessary parameters String cargs = "-w VCFVariantImportWorker -i " + inputFile.getAbsolutePath() + " -b " + String.valueOf(BENCHMARKING_BATCH_SIZE) + " -f " + initialFeatureSet.getSGID().getRowKey() + " -r " + reference.getSGID().getRowKey(); String command = "java -Xmx2048m -classpath " + System.getProperty("user.dir") + "/seqware-queryengine-0.12.0-full.jar com.github.seqware.queryengine.system.importers.SOFeatureImporter"; command = command + " " + cargs; command = "qsub -q long -l h_vmem=3G -cwd -N dyuen-" + inputFile.getName() + " -b y " + command; jobNames.append("dyuen-").append(inputFile.getName()).append(","); System.out.println("Running: " + command); CommandLine cmdLine = CommandLine.parse(command); DefaultExecutor executor = new DefaultExecutor(); int exitValue = executor.execute(cmdLine); } String jobs = jobNames.toString().substring(0, jobNames.length() - 1); // submit a job that just waits on all the preceding jobs for synchronization String command = "java -Xmx1024m -version"; command = "qsub -cwd -N dyuen-wait -hold_jid " + jobs + " -b y -sync y " + command; System.out.println("Running wait: " + command); CommandLine cmdLine = CommandLine.parse(command); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValues(null); int exitValue = executor.execute(cmdLine); FeatureSet fSet = SWQEFactory.getQueryInterface().getLatestAtomBySGID(initialFeatureSet.getSGID(), FeatureSet.class); keyValues.put(count + "-featuresSet-id", fSet.getSGID().getRowKey()); keyValues.put(count + "-featuresSet-id-timestamp", Long.toString(fSet.getSGID().getBackendTimestamp().getTime())); // // runs count query, touches everything but does not write // // keyValues.put(count + "-start-count-date-long", Long.toString(System.currentTimeMillis())); // long fsetcount = fSet.getCount(); // keyValues.put(count + "-features-loaded", Long.toString(fsetcount)); // keyValues.put(count + "-end-count-date-long", Long.toString(System.currentTimeMillis())); Date endDate = new Date(); keyValues.put(count + "-end-date-long", Long.toString(endDate.getTime())); keyValues.put(count + "-end-date-human", endDate.toString()); recordSpace(String.valueOf(count)); Utility.writeKeyValueFile(outputFile, keyValues); count++; }
From source file:com.hihframework.core.utils.DateUtils.java
/** * 23.59.59.999? param:2004-08-20,return:2004-08-31 * 23.59.59.999/*w w w. ja v a 2 s . com*/ * * @param date * @return */ public static Timestamp getMaxDayInMonth(java.sql.Date date) { Calendar cale = Calendar.getInstance(); cale.setTime(date); cale.set(Calendar.DAY_OF_MONTH, cale.getActualMaximum(Calendar.DAY_OF_MONTH)); java.sql.Date newDate = new java.sql.Date(cale.getTimeInMillis()); cale = null; return Timestamp.valueOf(newDate.toString() + " 23:59:59.999"); }
From source file:com.hihframework.core.utils.DateUtils.java
/** * ?00:00:00.000? param:2004-08-20 return:2004-08-01 * 00.00.00.000//from ww w .j a v a 2s . c o m * * @param date * @return ? */ public static Timestamp getMinDayInMonth(java.sql.Date date) { Calendar cale = Calendar.getInstance(); cale.setTime(date); cale.set(Calendar.DAY_OF_MONTH, cale.getActualMinimum(Calendar.DAY_OF_MONTH)); java.sql.Date newDate = new java.sql.Date(cale.getTimeInMillis()); cale = null; return Timestamp.valueOf(newDate.toString() + " 00:00:00.000"); }
From source file:uk.co.jassoft.markets.utils.article.ContentGrabber.java
private Date getDateValue(final String contentsToCheck) { if (contentsToCheck.isEmpty()) return null; Parser parser = new Parser(); List<DateGroup> groups = parser.parse(contentsToCheck); Date possibleDate = null;/*ww w .j a va 2 s . c om*/ for (DateGroup group : groups) { List<Date> dates = group.getDates(); for (Date publishedDate : dates) { if (new DateTime(DateTimeZone.UTC).plusDays(1).isBefore(publishedDate.getTime())) { LOG.debug("Date is over 1 day in the future [{}]", publishedDate.toString()); continue; } if (possibleDate == null) { possibleDate = publishedDate; if (group.isTimeInferred()) { possibleDate = new DateTime(publishedDate).withTime(0, 0, 0, 0).toDate(); } continue; } DateTime latestPublishedDate = new DateTime(publishedDate); if (!group.isTimeInferred()) { possibleDate = new DateTime(possibleDate).withTime(latestPublishedDate.getHourOfDay(), latestPublishedDate.getMinuteOfHour(), latestPublishedDate.getSecondOfMinute(), latestPublishedDate.getMillisOfSecond()).toDate(); } if (!group.isDateInferred()) { possibleDate = new DateTime(possibleDate).withDate(latestPublishedDate.getYear(), latestPublishedDate.getMonthOfYear(), latestPublishedDate.getDayOfMonth()).toDate(); } } } if (possibleDate != null) { return possibleDate; } return null; }
From source file:entity.Customer.java
public void setStartDate(Date startDate) { if (startDate == null) { Date date = new Date(); this.startDate = date; //LocalDate futureDate = LocalDate.now().plusMonths(2); // display time and date using toString() System.out.println(date.toString()); //System.out.println(futureDate); } else {//from w w w .j a v a 2 s . c o m this.startDate = startDate; } }
From source file:com.mothsoft.alexis.engine.numeric.TopicActivityDataSetImporter.java
private void importTopicDataForUser(final Long userId, final Date startDate, final Date endDate) { logger.debug(String.format("Importing topic activity for user: %d between %s and %s", userId, startDate.toString(), endDate.toString())); final List<Long> topicIds = this.transactionTemplate.execute(new TransactionCallback<List<Long>>() { @SuppressWarnings("unchecked") @Override/* w w w. j a v a2 s . co m*/ public List<Long> doInTransaction(TransactionStatus txStatus) { final Query query = TopicActivityDataSetImporter.this.em .createQuery("SELECT id FROM Topic WHERE userId = :userId ORDER BY id ASC"); query.setParameter("userId", userId); return query.getResultList(); } }); BigInteger total = BigInteger.ZERO; for (final Long topicId : topicIds) { BigInteger count = importTopicDataForTopic(topicId, startDate, endDate); total = total.add(count); } recordAggregateTopicActivity(userId, startDate, total); }