use of java.text.DateFormat in project stashbot by palantir.
the class BuildSuccessReportingServlet method getSuccessStatus.
private BuildStatus getSuccessStatus(Repository repo, JobTemplate jt, State state, long buildNumber, String buildHead) throws SQLException {
Date now = new Date(java.lang.System.currentTimeMillis());
DateFormat df = DateFormat.getDateInstance();
// key will be the jenkins name
String key = jt.getBuildNameFor(repo);
String name = key + " (build " + Long.toString(buildNumber) + ")";
String description = "Build " + Long.toString(buildNumber) + " " + state.toString() + " at " + df.format(now);
String url = getJenkinsUrl(repo, jt, buildNumber);
BuildStatus bs = new InternalBuildStatus(state, name, name, url, description, now);
return bs;
}
use of java.text.DateFormat in project processing by processing.
the class DetailPanel method setContribution.
public void setContribution(Contribution contrib) {
this.contrib = contrib;
if (contrib.isSpecial()) {
JLabel iconLabel = new JLabel(foundationIcon);
iconLabel.setBorder(new EmptyBorder(4, 7, 7, 7));
iconLabel.setVerticalAlignment(SwingConstants.TOP);
add(iconLabel, BorderLayout.WEST);
}
// Avoid ugly synthesized bold
Font boldFont = ManagerFrame.SMALL_BOLD;
String fontFace = "<font face=\"" + boldFont.getName() + "\">";
StringBuilder desc = new StringBuilder();
desc.append("<html><body>" + fontFace);
if (contrib.getUrl() == null) {
desc.append(contrib.getName());
} else {
desc.append("<a href=\"" + contrib.getUrl() + "\">" + contrib.getName() + "</a>");
}
desc.append("</font> ");
String prettyVersion = contrib.getPrettyVersion();
if (prettyVersion != null) {
desc.append(prettyVersion);
}
desc.append(" <br/>");
String authorList = contrib.getAuthorList();
if (authorList != null && !authorList.isEmpty()) {
desc.append(toHtmlLinks(contrib.getAuthorList()));
}
desc.append("<br/><br/>");
if (contrib.isDeletionFlagged()) {
desc.append(REMOVE_RESTART_MESSAGE);
} else if (contrib.isRestartFlagged()) {
desc.append(INSTALL_RESTART_MESSAGE);
} else if (contrib.isUpdateFlagged()) {
desc.append(UPDATE_RESTART_MESSAGE);
} else {
String sentence = contrib.getSentence();
if (sentence == null || sentence.isEmpty()) {
sentence = String.format("<i>%s</i>", Language.text("contrib.errors.description_unavailable"));
} else {
sentence = sanitizeHtmlTags(sentence);
sentence = toHtmlLinks(sentence);
}
desc.append(sentence);
}
long lastUpdatedUTC = contrib.getLastUpdated();
if (lastUpdatedUTC != 0) {
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
Date lastUpdatedDate = new Date(lastUpdatedUTC);
if (prettyVersion != null) {
desc.append(", ");
}
desc.append("Last Updated on " + dateFormatter.format(lastUpdatedDate));
}
desc.append("</body></html>");
description = desc.toString();
descriptionPane.setText(description);
if (contribListing.hasUpdates(contrib) && contrib.isCompatible(Base.getRevision())) {
StringBuilder versionText = new StringBuilder();
versionText.append("<html><body><i>");
if (contrib.isUpdateFlagged() || contrib.isDeletionFlagged()) {
// versionText.append("To finish an update, reinstall this contribution after restarting.");
;
} else {
String latestVersion = contribListing.getLatestPrettyVersion(contrib);
if (latestVersion != null) {
versionText.append("New version (" + latestVersion + ") available.");
} else {
versionText.append("New version available.");
}
}
versionText.append("</i></body></html>");
notificationLabel.setText(versionText.toString());
notificationLabel.setVisible(true);
} else {
notificationLabel.setText("");
notificationLabel.setVisible(false);
}
updateButton.setEnabled(true);
if (contrib != null) {
updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || updateInProgress);
}
if (contrib.isDeletionFlagged()) {
installRemoveButton.setText(undoText);
} else if (contrib.isInstalled()) {
installRemoveButton.setText(removeText);
installRemoveButton.setVisible(true);
installRemoveButton.setEnabled(!contrib.isUpdateFlagged());
reorganizePaneComponents();
} else {
installRemoveButton.setText(installText);
}
contextMenu.removeAll();
if (contrib.isInstalled()) {
contextMenu.add(openFolder);
setComponentPopupMenu(contextMenu);
} else {
setComponentPopupMenu(null);
}
if (!contrib.isCompatible(Base.getRevision())) {
blurContributionPanel(this);
}
}
use of java.text.DateFormat in project ratpack by ratpack.
the class GradleVersion method formatBuildTime.
private String formatBuildTime(Date buildTime) {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format.format(buildTime);
}
use of java.text.DateFormat in project android-saripaar by ragunathjawahar.
the class FutureRule method isValid.
@Override
public boolean isValid(final String dateString) {
DateFormat dateFormat = getDateFormat();
Date parsedDate = null;
try {
parsedDate = dateFormat.parse(dateString);
} catch (ParseException ignored) {
}
Date now = new Date();
return parsedDate != null && parsedDate.after(now);
}
use of java.text.DateFormat in project robolectric by robolectric.
the class RoboCookieManager method getExpiration.
private Date getExpiration(String field) {
int equalsIndex = field.indexOf("=");
if (equalsIndex < 0) {
return null;
}
String date = field.substring(equalsIndex + 1);
try {
DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
return dateFormat.parse(date);
} catch (ParseException e) {
// No-op. Try to inferFromValue additional date formats.
}
try {
DateFormat dateFormat = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss zzz");
return dateFormat.parse(date);
} catch (ParseException e) {
// Was not parsed by any date formatter.
return null;
}
}
Aggregations