public String toString() { return String.format("ProjectStatus[%s, %s, %s, %s, %s, %s, %s]", name, activity, lastBuildStatus, lastBuildLabel, DateUtils.formatISO8601(lastBuildTime) + "(" + lastBuildTime.getTime() + ")", webUrl, breakers); }
public void doAction() throws ParseException { DateUtils.parseISO8601("2009-09-11 11:11:21 +0800"); } });
public void doAction() throws ParseException { DateUtils.parseRFC822("Wed, 4 Jul 2001 12:08:56 -0700"); } });
private boolean isVersionInfoUpdatedToday() { Date latestVersionUpdatedAt = serverVersionInfo.getLatestVersionUpdatedAt(); if (latestVersionUpdatedAt == null) return false; return isToday(latestVersionUpdatedAt); }
@Test public void shouldSerializeDateForCcTray() { Date date = new DateTime("2008-12-09T18:56:14+08:00").toDate(); assertThat(DateUtils.formatIso8601ForCCTray(date), is("2008-12-09T10:56:14Z")); }
public void doAction() throws ParseException { DateUtils.parseYYYYMMDD("2018-12-31"); } });
public void commitOnDate(String message, Date commitDate) { HashMap<String, String> env = new HashMap<>(); env.put("GIT_AUTHOR_DATE", formatRFC822(commitDate)); CommandLine gitCmd = git(environment).withArgs("commit", "-m", message).withEnv(env).withWorkingDir(workingDir); runOrBomb(gitCmd); }
@Test public void shouldFormatDateToDisplayOnUI() { Calendar instance = Calendar.getInstance(); instance.set(2009, Calendar.NOVEMBER, 5); Date date = instance.getTime(); String formattedDate = DateUtils.formatToSimpleDate(date); assertThat(formattedDate, is("05 Nov 2009")); }
public static Date parseISO8601(String date) { try { DateTime dateTime = formatter.parseDateTime(date); return dateTime.toDate(); } catch (Exception e) { //fall through and try and parse other ISO standard formats } try { return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZZZ").parse(date); } catch (ParseException e) { //fall through and try and parse other ISO standard formats } try { return dateFormatFor("yyyy-MM-dd'T'HH:mm:ss").parse(date); } catch (ParseException e) { throw bomb(e); } }
public Element ccTrayXmlElement(String fullContextPath) { Element element = new Element("Project"); element.setAttribute("name", name); element.setAttribute("activity", activity); element.setAttribute("lastBuildStatus", lastBuildStatus); element.setAttribute("lastBuildLabel", lastBuildLabel); element.setAttribute("lastBuildTime", DateUtils.formatIso8601ForCCTray(lastBuildTime)); element.setAttribute("webUrl", fullContextPath + "/" + webUrl); if (!breakers.isEmpty()) { addBreakers(element); } return element; }
public String nullSafeDate(Date date) { return date == null ? ConvertedTime.NOT_AVAILABLE.toString() : formatISO8601(date); }
@Test public void shouldBeAbleToParseRFC822Dates() throws Exception { Date date = DateUtils.parseRFC822("Tue, 09 Dec 2008 18:56:14 +0800"); assertThat(date, is(new DateTime("2008-12-09T18:56:14+08:00").toDate())); }
public void processLine(String line) { Matcher matcher = COMMIT_PATTERN.matcher(line); if (matcher.matches()) { modifications.add(new Modification("", "", null, null, matcher.group(1))); } Matcher authorMatcher = AUTHOR_PATTERN.matcher(line); if (authorMatcher.matches()) { modifications.getLast().setUserName(authorMatcher.group(1)); } Matcher dateMatcher = DATE_PATTERN.matcher(line); if (dateMatcher.matches()) { modifications.getLast().setModifiedTime(DateUtils.parseISO8601(dateMatcher.group(1))); } Matcher commentMatcher = COMMENT_PATTERN.matcher(line); if (commentMatcher.matches()) { Modification last = modifications.getLast(); String comment = Optional.ofNullable(last.getComment()).orElse(""); if (!comment.isEmpty()) comment += "\n"; last.setComment(comment + commentMatcher.group(1)); } } }
public UsageStatisticsReporting get() { UsageStatisticsReporting loaded = usageStatisticsReportingSqlMapDao.load(); loaded.setDataSharingServerUrl(systemEnvironment.getGoDataSharingServerUrl()); loaded.setDataSharingGetEncryptionKeysUrl(systemEnvironment.getGoDataSharingGetEncryptionKeysUrl()); boolean canReport = !isDevelopmentServer() && dataSharingSettingsService.get().allowSharing() && !isToday(loaded.lastReportedAt()) && !isReportingInProgress(); loaded.canReport(canReport); return loaded; }
private Map<String, Object> serverInfoAsJson() { LinkedHashMap<String, Object> json = new LinkedHashMap<>(); json.put("Timestamp", DateUtils.formatISO8601(new Date())); for (ServerInfoProvider provider : providers) { try { json.put(provider.name(), provider.asJson()); } catch (Exception e) { json.put(provider.getClass().getCanonicalName(), String.format("Provider %s threw an exception: %s", provider.getClass(), e.getMessage())); LOGGER.warn("An API support page provider failed.", e); } } return json; } }
@Test public void shouldRetrieveLatestModification() throws Exception { Modification mod = git.latestModification().get(0); assertThat(mod.getUserName(), is("Chris Turner <cturner@thoughtworks.com>")); assertThat(mod.getComment(), is("Added 'run-till-file-exists' ant target")); assertThat(mod.getModifiedTime(), is(parseRFC822("Fri, 12 Feb 2010 16:12:04 -0800"))); assertThat(mod.getRevision(), is("5def073a425dfe239aabd4bf8039ffe3b0e8856b")); List<ModifiedFile> files = mod.getModifiedFiles(); assertThat(files.size(), is(1)); assertThat(files.get(0).getFileName(), is("build.xml")); assertThat(files.get(0).getAction(), Matchers.is(ModifiedAction.modified)); }
@Test public void shouldHaveCommitDate() { simulateOneComment(); assertThat( parser.getModifications().get(0).getModifiedTime(), is(DateUtils.parseISO8601("2009-08-11 13:08:51 -0700"))); }
public void doAction() throws ParseException { DateUtils.formatISO8601(new Date()); } });
private Modification parseChangeset(Element changeset) { Date modifiedTime = DateUtils.parseRFC822(changeset.getChildText("date")); String author = org.apache.commons.lang3.StringEscapeUtils.unescapeXml(changeset.getChildText("author")); String comment = org.apache.commons.lang3.StringEscapeUtils.unescapeXml(changeset.getChildText("desc")); String revision = changeset.getChildText("node"); Modification modification = new Modification(author, comment, null, modifiedTime, revision); Element files = changeset.getChild("files"); List<File> modifiedFiles = parseFiles(files, "modified"); List<File> addedFiles = parseFiles(files, "added"); List<File> deletedFiles = parseFiles(files, "deleted"); modifiedFiles.removeAll(addedFiles); modifiedFiles.removeAll(deletedFiles); addModificationFiles(modification, ModifiedAction.added, addedFiles); addModificationFiles(modification, ModifiedAction.deleted, deletedFiles); addModificationFiles(modification, ModifiedAction.modified, modifiedFiles); return modification; }