List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:io.dockstore.client.cli.nested.ToolClient.java
@Override public void handleInfo(String entryPath) { try {//w ww .j a v a 2 s . c o m DockstoreTool container = containersApi.getPublishedContainerByToolPath(entryPath); if (container == null || !container.getIsPublished()) { errorMessage("This container is not published.", Client.COMMAND_ERROR); } else { Date dateUploaded = container.getLastBuild(); String description = container.getDescription(); if (description == null) { description = ""; } String author = container.getAuthor(); if (author == null) { author = ""; } String date = ""; if (dateUploaded != null) { date = dateUploaded.toString(); } out(""); out("DESCRIPTION:"); out(description); out("AUTHOR:"); out(author); out("DATE UPLOADED:"); out(date); out("TAGS"); List<Tag> tags = container.getTags(); int tagSize = tags.size(); StringBuilder builder = new StringBuilder(); if (tagSize > 0) { builder.append(tags.get(0).getName()); for (int i = 1; i < tagSize; i++) { builder.append(", ").append(tags.get(i).getName()); } } out(builder.toString()); out("GIT REPO:"); out(container.getGitUrl()); out("QUAY.IO REPO:"); out("http://quay.io/repository/" + container.getNamespace() + "/" + container.getName()); // out(container.toString()); } } catch (ApiException ex) { exceptionMessage(ex, "Could not find container", Client.API_ERROR); } }
From source file:com.clustercontrol.calendar.factory.SelectCalendar.java
public ArrayList<CalendarDetailInfo> getCalendarWeek(CalendarInfo info, Integer year, Integer month, Integer day) throws CalendarNotFound { m_log.trace("calendarId:" + info.getCalendarId() + ", year:" + year + ", month:" + month + ", day:" + day); long validFrom = info.getValidTimeFrom(); long validTo = info.getValidTimeTo(); ArrayList<CalendarDetailInfo> ret = new ArrayList<CalendarDetailInfo>(); Calendar startCalendar = HinemosTime.getCalendarInstance(); startCalendar.clear();//from w w w . ja v a2 s . co m startCalendar.set(year, month - 1, day, 0, 0, 0); long startTime = startCalendar.getTimeInMillis(); Calendar endCalendar = HinemosTime.getCalendarInstance(); endCalendar.clear(); endCalendar.set(year, month - 1, day + 1, 0, 0, 0); long endTime = endCalendar.getTimeInMillis(); if (startTime <= validFrom && endTime <= validFrom) { return ret; } if (validTo <= startTime && validTo <= endTime) { return ret; } if (startTime < validFrom && validFrom < endTime) { CalendarDetailInfo detail = new CalendarDetailInfo(); detail.setTimeFrom(0 - TIMEZONE); detail.setTimeTo(validFrom - startTime - TIMEZONE); detail.setOperateFlg(false); detail.setOrderNo(-2);// ? m_log.trace("start<validfrom && validfrom<endttime add"); ret.add(detail); } if (startTime < validTo && validTo < endTime) { CalendarDetailInfo detail = new CalendarDetailInfo(); detail.setTimeFrom(validTo - startTime - TIMEZONE); detail.setTimeTo(HOUR24 - TIMEZONE); detail.setOperateFlg(false); detail.setOrderNo(-1);// ? m_log.trace("start<validto && validto<endttime add"); ret.add(detail); } // client?????CalendarDetailList??? // ????????? startCalendar.clear(); startCalendar.set(year, month - 1, day, 0, 0, 0); ArrayList<Date> checkDateList = new ArrayList<>(); int onesec = 1 * 1000; Long startLong = startCalendar.getTime().getTime(); ArrayList<CalendarDetailInfo> substituteList = new ArrayList<>(); for (CalendarDetailInfo detailInfo : info.getCalendarDetailList()) { int timezone = HinemosTime.getTimeZoneOffset(); // start_time checkDateList.add(new Date(startLong + detailInfo.getTimeFrom() + timezone)); checkDateList.add(new Date(startLong + detailInfo.getTimeFrom() - onesec + timezone));// 1second?? checkDateList.add(new Date(startLong + detailInfo.getTimeFrom() + onesec + timezone));// 1second? // end_time checkDateList.add(new Date(startLong + detailInfo.getTimeTo() + timezone)); checkDateList.add(new Date(startLong + detailInfo.getTimeTo() - onesec + timezone)); checkDateList.add(new Date(startLong + detailInfo.getTimeTo() + onesec + timezone)); if (detailInfo.isSubstituteFlg()) { // ????????? substituteList.add(detailInfo); } } // getDetail24??????? ArrayList<CalendarDetailInfo> detailList = new ArrayList<>(); for (CalendarDetailInfo detail : info.getCalendarDetailList()) { detailList.addAll(CalendarUtil.getDetail24(detail)); } for (CalendarDetailInfo detailInfo : detailList) { int timezone = HinemosTime.getTimeZoneOffset(); // start_time checkDateList.add(new Date(startLong + detailInfo.getTimeFrom() + timezone)); checkDateList.add(new Date(startLong + detailInfo.getTimeFrom() - onesec + timezone));// 1second?? checkDateList.add(new Date(startLong + detailInfo.getTimeFrom() + onesec + timezone));// 1second? // end_time checkDateList.add(new Date(startLong + detailInfo.getTimeTo() + timezone)); checkDateList.add(new Date(startLong + detailInfo.getTimeTo() - onesec + timezone)); checkDateList.add(new Date(startLong + detailInfo.getTimeTo() + onesec + timezone)); } // ????????????? ArrayList<Date> checkDateListSub = new ArrayList<>(); for (Date checkDate : checkDateList) { for (CalendarDetailInfo detailInfo : substituteList) { Long checkDateLong = checkDate.getTime(); checkDateListSub .add(new Date(checkDateLong - (CalendarUtil.parseDate(detailInfo.getSubstituteTime()) + HinemosTime.getTimeZoneOffset()))); } } checkDateList.addAll(checkDateListSub); // ?valid_time_from?valid_time_to checkDateList.add(new Date(info.getValidTimeFrom())); checkDateList.add(new Date(info.getValidTimeTo())); // list?????? checkDateList = new ArrayList<>(new HashSet<>(checkDateList)); // list? Collections.sort(checkDateList); m_log.trace("checkDateList.size:" + checkDateList.size()); ArrayList<CalendarDetailInfo> detailSubsList = new ArrayList<>(); for (Date targetDate : checkDateList) { Calendar targetCal = Calendar.getInstance(); targetCal.setTime(targetDate); // ???????????? if (startCalendar.get(Calendar.YEAR) != targetCal.get(Calendar.YEAR) || startCalendar.get(Calendar.MONTH) != targetCal.get(Calendar.MONTH) || startCalendar.get(Calendar.DATE) != targetCal.get(Calendar.DATE)) { continue; } m_log.trace("startCalendar:" + targetDate); ArrayList<CalendarDetailInfo> detailList2 = new ArrayList<>(); Date substituteDate = new Date(targetDate.getTime()); // detailList2????CalendarDetailInfo? Object[] retObjArr = CalendarUtil.getCalendarRunDetailInfo(info, targetDate, detailList2); boolean isrun = (Boolean) retObjArr[0]; // ?2?????? if (retObjArr.length == 2) { substituteDate.setTime(((Date) retObjArr[1]).getTime()); } m_log.trace("id:" + info.getCalendarId() + ", startCalendar:" + targetDate + ", detailList2.size:" + detailList2.size() + ", isrun:" + isrun + ", substituteDate:" + substituteDate.toString()); // ?CalendarDetailInfo????????????getDetail24????? for (CalendarDetailInfo detailInfo : detailList2) { ArrayList<CalendarDetailInfo> calendarDetailList = CalendarUtil.getDetail24(detailInfo); for (CalendarDetailInfo detail24 : calendarDetailList) { if (CalendarUtil.isRunByDetailDateTime(detail24, substituteDate) && !detailSubsList.contains(detail24)) { detailSubsList.add(detail24); m_log.trace("add to ret. orderNo:" + detail24.getOrderNo() + ", description:" + detail24.getDescription() + ", isOperation:" + detail24.isOperateFlg() + ", from:" + detail24.getTimeFrom() + ", to:" + detail24.getTimeTo()); } } } } ret.addAll(detailSubsList); Collections.sort(ret, new Comparator<CalendarDetailInfo>() { public int compare(CalendarDetailInfo obj0, CalendarDetailInfo obj1) { int order1 = obj0.getOrderNo(); int order2 = obj1.getOrderNo(); int ret = order1 - order2; return ret; } }); if (m_log.isDebugEnabled()) { for (CalendarDetailInfo detail : ret) { m_log.debug("detail=" + detail); } } m_log.trace("ret.size:" + ret.size()); return ret; }
From source file:com.google.ytd.SubmitActivity.java
public void submitToYtdDomain(String ytdDomain, String assignmentId, String videoId, String youTubeName, String clientLoginToken, String title, String description, Date dateTaken, String videoLocation, String tags) {//from w w w .j a v a2s. c o m JSONObject payload = new JSONObject(); try { payload.put("method", "NEW_MOBILE_VIDEO_SUBMISSION"); JSONObject params = new JSONObject(); params.put("videoId", videoId); params.put("youTubeName", youTubeName); params.put("clientLoginToken", clientLoginToken); params.put("title", title); params.put("description", description); params.put("videoDate", dateTaken.toString()); params.put("tags", tags); if (videoLocation != null) { params.put("videoLocation", videoLocation); } if (assignmentId != null) { params.put("assignmentId", assignmentId); } payload.put("params", params); } catch (JSONException e) { e.printStackTrace(); } String jsonRpcUrl = "http://" + ytdDomain + "/jsonrpc"; String json = Util.makeJsonRpcCall(jsonRpcUrl, payload); if (json != null) { try { JSONObject jsonObj = new JSONObject(json); } catch (JSONException e) { e.printStackTrace(); } } }
From source file:org.clapper.curn.FeedDownloadThread.java
/** * Determine whether an item is cached.//from w ww.j a v a 2 s .c o m * * @param item the item to test * @param itemURL the item's normalized URL (which might not be the * same as the URL in the item itself) * * @return true if cached, false if not */ private boolean itemIsNew(final RSSItem item, final URL itemURL) { String itemURLString = itemURL.toString(); boolean isNew = true; FeedCacheEntry cacheEntry = cache.getEntryForItem(item); if (cacheEntry == null) { log.debug("URL \"" + itemURLString + "\" is not in the cache. It's new."); } else if (cacheEntry.isSticky()) { log.debug("URL \"" + itemURLString + "\" is marked sticky. " + "Treating it as new."); isNew = true; } else { Date cachePubDate = cacheEntry.getPublicationDate(); Date itemPubDate = item.getPublicationDate(); log.debug("URL \"" + itemURLString + "\" is cached and non-sticky."); if ((cachePubDate == null) || (itemPubDate == null)) { log.debug("Missing publication date in item and/or " + "cache for URL \"" + itemURLString + "\". Assuming URL is old, since it is in the " + "cache. Skipping it."); isNew = false; } else { log.debug("URL \"" + itemURLString + "\": Cached publication date is " + cachePubDate.toString() + "\", item publication date is " + itemPubDate); if (itemPubDate.after(cachePubDate)) { log.debug("URL \"" + itemURLString + "\" is newer than cached publication date. " + "Keeping it."); } else { log.debug("URL \"" + itemURLString + "\" is not newer than cached publication date. " + "Skipping it."); isNew = false; } } } log.debug("URL \"" + itemURLString + "\" is new? " + isNew); return isNew; }
From source file:org.etudes.mneme.impl.QuestionStorageSql.java
/** * {@inheritDoc}/* w w w .j a va2 s .c o m*/ */ public List<String> clearStaleMintQuestions(final Date stale) { final List<String> rv = new ArrayList<String>(); this.sqlService.transact(new Runnable() { public void run() { clearStaleMintQuestionsTx(stale, rv); } }, "clearStaleMintQuestions: " + stale.toString()); return rv; }
From source file:edu.ku.brc.specify.tools.datamodelgenerator.DatamodelGenerator.java
/** * Takes a list and prints out data model file using betwixt. * @param classesList the class list/*from w w w . j a va2s . c om*/ */ public boolean writeTree(final List<Table> classesList) { if (doRelsToZeroToOne) { for (Table tbl : classesList) { adjustRelsForZeroToOne(tbl); } } try { if (classesList == null) { log.error("Datamodel information is null - datamodel file will not be written!!"); return false; } log.info("writing data model tree to file: " + DatamodelHelper.getDatamodelFilePath()); File file = DatamodelHelper.getDatamodelFilePath(); FileWriter fw = new FileWriter(file); fw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); fw.write("<!-- \n"); fw.write(" Do Not Edit this file!\n"); fw.write(" Run DatamodelGenerator \n"); Date date = new Date(); fw.write(" Generated: " + date.toString() + "\n"); fw.write("-->\n"); //using betwixt for writing out datamodel file. associated .betwixt files allow you to map and define //output format of attributes in xml file. BeanWriter beanWriter = new BeanWriter(fw); XMLIntrospector introspector = beanWriter.getXMLIntrospector(); introspector.getConfiguration().setWrapCollectionsInElement(false); beanWriter.getBindingConfiguration().setMapIDs(false); beanWriter.setWriteEmptyElements(false); beanWriter.enablePrettyPrint(); beanWriter.write("database", classesList); fw.close(); return true; } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DatamodelGenerator.class, ex); log.error("error writing writeTree", ex); return false; } }
From source file:net.sourceforge.seqware.common.metadata.MetadataWSTest.java
protected void testTimestamp(String sql, final String colname, Date beforeDate) { logger.debug(sql);/* www . ja va 2 s . co m*/ try { Date date = DBAccess.get().executeQuery(sql, new ResultSetHandler<Date>() { @Override public Date handle(ResultSet rs) throws SQLException { if (rs.next()) { return rs.getTimestamp(colname); } else { return null; } } }); if (date != null) { if (date.before(beforeDate)) { logger.debug("before " + beforeDate.toString()); logger.debug("update " + date.toString()); Assert.fail("Update failed."); } } else { Assert.fail("No rows in ResultSet"); } } catch (SQLException ex) { ex.printStackTrace(); Assert.fail("SQL Exception"); } finally { DBAccess.close(); } }
From source file:uk.ac.soton.itinnovation.sad.service.services.SchedulingService.java
/** * Converts schedule from JSON string to Quartz trigger. * * @return Plugin schedule as Quartz trigger. *//*w ww .java 2 s.c o m*/ private Trigger jsonScheduleToTrigger(JSONObject schedule, String triggerName, String triggerId) { Trigger trigger; Date timeNow = new Date(); String startAt = null, endAt = null, times = null, withIntervalInMilliseconds = null; if (schedule.containsKey("startAt")) { startAt = schedule.getString("startAt"); logger.debug("Quartz scheduler got \"startAt\": \"" + startAt + "\" (" + Util.i2d(startAt) + ")"); } else { logger.debug("Quartz scheduler parameter \"startAt\": NOT SET"); } if (schedule.containsKey("endAt")) { endAt = schedule.getString("endAt"); logger.debug("Quartz scheduler got \"endAt\": \"" + endAt + "\" (" + Util.i2d(endAt) + ")"); } else { logger.debug("Quartz scheduler parameter \"endAt\": NOT SET"); } if (schedule.containsKey("times")) { times = schedule.getString("times"); logger.debug("Quartz scheduler got \"times\": \"" + times + "\""); } else { logger.debug("Quartz scheduler parameter \"withRepeatCount\": NOT SET"); } if (schedule.containsKey("withIntervalInMilliseconds")) { withIntervalInMilliseconds = schedule.getString("withIntervalInMilliseconds"); logger.debug( "Quartz scheduler got \"withIntervalInMilliseconds\": \"" + withIntervalInMilliseconds + "\""); } else { logger.debug("Quartz scheduler parameter \"withIntervalInMilliseconds\": NOT SET"); } SimpleScheduleBuilder quartzSchedule = SimpleScheduleBuilder.simpleSchedule(); logger.debug("Time now: " + timeNow); if ((startAt != null) && (endAt != null)) { List<Date> triggerDates = TriggerUtils.computeFireTimesBetween( (OperableTrigger) TriggerBuilder.newTrigger().build(), new BaseCalendar(), new Date(Long.parseLong(startAt)), new Date(Long.parseLong(endAt))); int newRepeatCount = triggerDates.size(); // logger.warn("Setting new value for \"withRepeatCount\" based on start and end dates: \"" + newRepeatCount + "\""); logger.warn("Setting new value for \"withRepeatCount\" based on start and end dates: \"" + newRepeatCount + "\""); quartzSchedule = quartzSchedule.withRepeatCount(newRepeatCount); logger.debug("New Schedule:"); for (Date d : triggerDates) { logger.debug("\t" + d.toString()); } } else if ((startAt == null) && (endAt != null)) { List<Date> triggerDates = TriggerUtils.computeFireTimesBetween( (OperableTrigger) TriggerBuilder.newTrigger().build(), new BaseCalendar(), timeNow, new Date(Long.parseLong(endAt))); int newRepeatCount = triggerDates.size(); // logger.warn("Setting new value for \"withRepeatCount\" based on start and end dates: \"" + newRepeatCount + "\""); logger.warn("Setting new value for \"withRepeatCount\" based on start and end dates: \"" + newRepeatCount + "\""); quartzSchedule = quartzSchedule.withRepeatCount(newRepeatCount); logger.debug("New Schedule:"); for (Date d : triggerDates) { logger.debug("\t" + d.toString()); } } else { if (times == null) { logger.debug("Using DEFAULT value of 0 for \"withRepeatCount\" for quartz scheduler"); quartzSchedule = quartzSchedule.withRepeatCount(0); } else { logger.debug("Using \"withRepeatCount\" value for quartz scheduler: \"" + (Integer.parseInt(times) - 1) + "\""); quartzSchedule = quartzSchedule.withRepeatCount(Integer.parseInt(times) - 1); } } if (withIntervalInMilliseconds == null) { logger.warn("Using DEFAULT value of 5 minutes (300000 msec) for \"withIntervalInMilliseconds\"!"); quartzSchedule = quartzSchedule.withIntervalInMilliseconds(300000L); } else { logger.debug("Using \"withIntervalInMilliseconds\" value for quartz scheduler: \"" + withIntervalInMilliseconds + "\""); quartzSchedule = quartzSchedule.withIntervalInMilliseconds(Long.parseLong(withIntervalInMilliseconds)); } if (startAt == null) { trigger = TriggerBuilder.newTrigger().withIdentity("trigger:" + triggerName, "job: " + triggerId) .startNow().withSchedule(quartzSchedule).build(); } else { trigger = TriggerBuilder.newTrigger().withIdentity("trigger:" + triggerName, "job: " + triggerId) .startAt(new Date(Integer.parseInt(startAt))).withSchedule(quartzSchedule).build(); } return trigger; }
From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeTime.java
public boolean snapshotCreation(AmazonEC2Client ec2Client, Volume vol, String period, Date date) { if ((date == null) | (ec2Client == null) | (vol == null) | (period == null)) { return false; }//from w w w . j av a 2 s . c om try { if ("day".equalsIgnoreCase(period)) { } else if ("hour".equalsIgnoreCase(period)) { } else if ("week".equalsIgnoreCase(period)) { } else if ("month".equalsIgnoreCase(period)) { } else { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\""); return false; } Collection<Tag> tags_volume = getResourceTags(vol); String volumeAttachmentInstance = "none"; try { volumeAttachmentInstance = vol.getAttachments().get(0).getInstanceId(); } catch (Exception e) { logger.debug("Volume not attached to instance: " + vol.getVolumeId()); } String description = period + "_snapshot " + vol.getVolumeId() + " by Eidetic at " + date.toString() + ". Volume attached to " + volumeAttachmentInstance; Snapshot current_snap; try { current_snap = createSnapshotOfVolume(ec2Client, vol, description, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); return false; } try { setResourceTags(ec2Client, current_snap, tags_volume, numRetries_, maxApiRequestsPerSecond_, uniqueAwsAccountIdentifier_); } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event\"Error\", Error=\"error adding tags to snapshot\", Snapshot_id=\"" + current_snap.getVolumeId() + "\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); return false; } } catch (Exception e) { logger.error("awsAccountNickname=\"" + uniqueAwsAccountIdentifier_ + "\",Event=\"Error, Error=\"error in snapshotCreation\", stacktrace=\"" + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\""); return false; } return true; }
From source file:org.linagora.linshare.core.service.impl.UploadRequestServiceImpl.java
/** * Check if the current input date is after now and not before now more the * functionality duration if delegation policy allowed it. * now() < currentDate < now() + func.value * Otherwise functionality value is used as default value. * @param func/*from ww w. j a v a 2 s .c o m*/ * @param currentDate * @return the proper date is returned according to activation policy, * configuration policy and others checks. */ private Date checkDate(TimeUnitValueFunctionality func, Date currentDate) { if (func.getActivationPolicy().getStatus()) { logger.debug(func.getIdentifier() + " is activated"); Calendar c = new GregorianCalendar(); c.add(func.toCalendarValue(), func.getValue()); Date maxDate = c.getTime(); if (func.getDelegationPolicy() != null && func.getDelegationPolicy().getStatus()) { logger.debug(func.getIdentifier() + " has a delegation policy"); if (currentDate != null) { if (currentDate.after(maxDate) || currentDate.before(new Date())) { logger.warn("the current value " + currentDate.toString() + " is out of range : " + func.toString() + " : " + maxDate.toString()); return maxDate; } else { return currentDate; } } return maxDate; } else { // there is no delegation, the current value should be the // system value or null logger.debug(func.getIdentifier() + " does not have a delegation policy"); if (currentDate != null) { if (!currentDate.equals(maxDate)) { logger.warn("the current value " + currentDate.toString() + " is different than system value " + maxDate); } } return maxDate; } } else { logger.debug(func.getIdentifier() + " is not activated"); if (currentDate != null) { logger.warn("the current value " + currentDate.toString() + " should be null for the functionality " + func.toString()); } return null; } }